class ProxyHelper {

   static boolean isHostMatchesNonProxyHostsPattern( String host, String nonProxyHostsPattern )
   {
       boolean matches = true;
       if ( StringUtils.isNotBlank( nonProxyHostsPattern ) )
       {
           try
           {
               matches = host.matches( nonProxyHostsPattern );
           }
           catch ( PatternSyntaxException e )
           {
               String message = String.format( "Invalid pattern for non-proxy hosts: '%s'", nonProxyHostsPattern );
               log.warn( message, e );
               matches = false;
           }
       }
       String format = "isHostMatchesNonProxyHostsPattern( host = '{}', nonProxyHostsPattern = '{}' ): {}";
       log.debug( format, host, nonProxyHostsPattern, matches );
       return matches;
   }

}

class ProxyHelperTest {

    public static final String PATTERN;
    public static final String HOST;
    public static final String SOURCE_URL;

    @Test
    public void testIsHostMatchesNonProxyHostsPattern(   )
    {

        String javaPattern = ProxyHelper.convertToJavaPattern( PATTERN );
        boolean matches = ProxyHelper.isHostMatchesNonProxyHostsPattern( HOST, javaPattern );
        String message = String.format( "host '%s' must match pattern '%s'", HOST, PATTERN );
        assertTrue( message, matches );
    }

}