boolean (final @NotNull Pattern pattern, final @NotNull String s) { try { return pattern.matcher(StringUtil.newBombedCharSequence(s, 300)).matches(); } catch (ProcessCanceledException e) { // something wrong with the pattern, infinite cycle? Logger.getInstance(JsonSchemaObject.class).info("Pattern matching canceled"); return false; } catch (Exception e) { // catch exceptions around to prevent things like: // https://bugs.openjdk.org/browse/JDK-6984178 Logger.getInstance(JsonSchemaObject.class).info(e); return false; } }