diff --git a/src/main/java/com/github/fge/jsonschema/exceptions/InvalidInstanceException.java b/src/main/java/com/github/fge/jsonschema/exceptions/InvalidInstanceException.java index f50d10a70..ef609b49b 100644 --- a/src/main/java/com/github/fge/jsonschema/exceptions/InvalidInstanceException.java +++ b/src/main/java/com/github/fge/jsonschema/exceptions/InvalidInstanceException.java @@ -28,6 +28,8 @@ public final class InvalidInstanceException extends ProcessingException { + private static final long serialVersionUID = -3273787152985150466L; + public InvalidInstanceException(final ProcessingMessage message) { super(message); diff --git a/src/main/java/com/github/fge/jsonschema/format/common/DateTimeAttribute.java b/src/main/java/com/github/fge/jsonschema/format/common/DateTimeAttribute.java index 20a4a9821..8aae60ad2 100644 --- a/src/main/java/com/github/fge/jsonschema/format/common/DateTimeAttribute.java +++ b/src/main/java/com/github/fge/jsonschema/format/common/DateTimeAttribute.java @@ -31,8 +31,6 @@ import org.joda.time.format.DateTimeFormatterBuilder; import org.joda.time.format.DateTimeParser; -import java.util.List; - import static org.joda.time.DateTimeFieldType.*; /** @@ -41,7 +39,7 @@ public final class DateTimeAttribute extends AbstractFormatAttribute { - private static final List FORMATS = ImmutableList.of( + private static final ImmutableList FORMATS = ImmutableList.of( "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}Z" ); private static final DateTimeFormatter FORMATTER; diff --git a/src/main/java/com/github/fge/jsonschema/format/common/RFC3339DateTimeAttribute.java b/src/main/java/com/github/fge/jsonschema/format/common/RFC3339DateTimeAttribute.java index 80a42ae75..73c1e12af 100644 --- a/src/main/java/com/github/fge/jsonschema/format/common/RFC3339DateTimeAttribute.java +++ b/src/main/java/com/github/fge/jsonschema/format/common/RFC3339DateTimeAttribute.java @@ -1,7 +1,5 @@ package com.github.fge.jsonschema.format.common; -import java.util.List; - import com.github.fge.jsonschema.cfg.ValidationConfiguration; import com.github.fge.jsonschema.library.DraftV4Library; import org.joda.time.format.DateTimeFormatter; @@ -31,7 +29,7 @@ */ public class RFC3339DateTimeAttribute extends AbstractFormatAttribute { - private static final List RFC3339_FORMATS = ImmutableList.of( + private static final ImmutableList RFC3339_FORMATS = ImmutableList.of( "yyyy-MM-dd'T'HH:mm:ss((+|-)HH:mm|Z)", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}((+|-)HH:mm|Z)" ); diff --git a/src/main/java/com/github/fge/jsonschema/format/common/RegexAttribute.java b/src/main/java/com/github/fge/jsonschema/format/common/RegexAttribute.java index 9db53adee..f20127c19 100644 --- a/src/main/java/com/github/fge/jsonschema/format/common/RegexAttribute.java +++ b/src/main/java/com/github/fge/jsonschema/format/common/RegexAttribute.java @@ -22,7 +22,7 @@ import com.github.fge.jackson.NodeType; import com.github.fge.jsonschema.core.exceptions.ProcessingException; import com.github.fge.jsonschema.core.report.ProcessingReport; -import com.github.fge.jsonschema.core.util.RhinoHelper; +import com.github.fge.jsonschema.core.util.RegexECMA262Helper; import com.github.fge.jsonschema.format.AbstractFormatAttribute; import com.github.fge.jsonschema.format.FormatAttribute; import com.github.fge.jsonschema.processors.data.FullData; @@ -34,7 +34,7 @@ *

Again, here, we do not use {@link java.util.regex} because it does * not fit the bill.

* - * @see RhinoHelper + * @see RegexECMA262Helper */ public final class RegexAttribute extends AbstractFormatAttribute @@ -58,7 +58,7 @@ public void validate(final ProcessingReport report, { final String value = data.getInstance().getNode().textValue(); - if (!RhinoHelper.regexIsValid(value)) + if (!RegexECMA262Helper.regexIsValid(value)) report.error(newMsg(data, bundle, "err.format.invalidRegex") .putArgument("value", value)); } diff --git a/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv3/DraftV3DependenciesDigester.java b/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv3/DraftV3DependenciesDigester.java index 386bb07bb..683dc962d 100644 --- a/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv3/DraftV3DependenciesDigester.java +++ b/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv3/DraftV3DependenciesDigester.java @@ -91,6 +91,9 @@ public JsonNode digest(final JsonNode schema) case STRING: propertyDeps.put(key, FACTORY.arrayNode() .add(value.textValue())); + break; + default: + break; } } diff --git a/src/main/java/com/github/fge/jsonschema/keyword/validator/common/AdditionalPropertiesValidator.java b/src/main/java/com/github/fge/jsonschema/keyword/validator/common/AdditionalPropertiesValidator.java index b466ba678..1741dad02 100644 --- a/src/main/java/com/github/fge/jsonschema/keyword/validator/common/AdditionalPropertiesValidator.java +++ b/src/main/java/com/github/fge/jsonschema/keyword/validator/common/AdditionalPropertiesValidator.java @@ -25,7 +25,7 @@ import com.github.fge.jsonschema.core.exceptions.ProcessingException; import com.github.fge.jsonschema.core.processing.Processor; import com.github.fge.jsonschema.core.report.ProcessingReport; -import com.github.fge.jsonschema.core.util.RhinoHelper; +import com.github.fge.jsonschema.core.util.RegexECMA262Helper; import com.github.fge.jsonschema.keyword.validator.AbstractKeywordValidator; import com.github.fge.jsonschema.processors.data.FullData; import com.github.fge.msgsimple.bundle.MessageBundle; @@ -84,7 +84,7 @@ public void validate(final Processor processor, for (final String field: fields) for (final String regex: patternProperties) - if (RhinoHelper.regMatch(regex, field)) + if (RegexECMA262Helper.regMatch(regex, field)) tmp.add(field); fields.removeAll(tmp); diff --git a/src/main/java/com/github/fge/jsonschema/keyword/validator/common/PatternValidator.java b/src/main/java/com/github/fge/jsonschema/keyword/validator/common/PatternValidator.java index 653428a27..5bce7ea79 100644 --- a/src/main/java/com/github/fge/jsonschema/keyword/validator/common/PatternValidator.java +++ b/src/main/java/com/github/fge/jsonschema/keyword/validator/common/PatternValidator.java @@ -23,7 +23,7 @@ import com.github.fge.jsonschema.core.exceptions.ProcessingException; import com.github.fge.jsonschema.core.processing.Processor; import com.github.fge.jsonschema.core.report.ProcessingReport; -import com.github.fge.jsonschema.core.util.RhinoHelper; +import com.github.fge.jsonschema.core.util.RegexECMA262Helper; import com.github.fge.jsonschema.keyword.validator.AbstractKeywordValidator; import com.github.fge.jsonschema.processors.data.FullData; import com.github.fge.msgsimple.bundle.MessageBundle; @@ -31,7 +31,7 @@ /** * Keyword validator for {@code pattern} * - * @see RhinoHelper + * @see RegexECMA262Helper */ public final class PatternValidator extends AbstractKeywordValidator @@ -50,7 +50,7 @@ public void validate(final Processor processor, final String regex = data.getSchema().getNode().get(keyword) .textValue(); final String value = data.getInstance().getNode().textValue(); - if (!RhinoHelper.regMatch(regex, value)) + if (!RegexECMA262Helper.regMatch(regex, value)) report.error(newMsg(data, bundle, "err.common.pattern.noMatch") .putArgument("regex", regex).putArgument("string", value)); } diff --git a/src/main/java/com/github/fge/jsonschema/main/cli/CustomHelpFormatter.java b/src/main/java/com/github/fge/jsonschema/main/cli/CustomHelpFormatter.java index 95c6eaa4a..752fd7bb3 100644 --- a/src/main/java/com/github/fge/jsonschema/main/cli/CustomHelpFormatter.java +++ b/src/main/java/com/github/fge/jsonschema/main/cli/CustomHelpFormatter.java @@ -34,7 +34,7 @@ final class CustomHelpFormatter implements HelpFormatter { - private static final List HELP_PREAMBLE = ImmutableList.of( + private static final ImmutableList HELP_PREAMBLE = ImmutableList.of( "Syntax:", " java -jar jsonschema.jar [options] schema file [file...]", " java -jar jsonschema.jar --syntax [options] schema [schema...]", @@ -42,7 +42,7 @@ final class CustomHelpFormatter "Options: " ); - private static final List HELP_POST + private static final ImmutableList HELP_POST = ImmutableList.builder() .add("") .add("Exit codes:") diff --git a/src/main/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaSelector.java b/src/main/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaSelector.java index 91e63a10a..9ddc1f3bb 100644 --- a/src/main/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaSelector.java +++ b/src/main/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaSelector.java @@ -21,7 +21,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.github.fge.jackson.jsonpointer.JsonPointer; -import com.github.fge.jsonschema.core.util.RhinoHelper; +import com.github.fge.jsonschema.core.util.RegexECMA262Helper; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -73,7 +73,7 @@ public Iterable selectSchemas(final String memberName) list.add(PROPERTIES.append(memberName)); for (final String regex: patternProperties) - if (RhinoHelper.regMatch(regex, memberName)) + if (RegexECMA262Helper.regMatch(regex, memberName)) list.add(PATTERNPROPERTIES.append(regex)); if (!list.isEmpty()) diff --git a/src/main/java/com/github/fge/jsonschema/processors/validation/ValidationStack.java b/src/main/java/com/github/fge/jsonschema/processors/validation/ValidationStack.java index 0759cb87f..ea31f1730 100644 --- a/src/main/java/com/github/fge/jsonschema/processors/validation/ValidationStack.java +++ b/src/main/java/com/github/fge/jsonschema/processors/validation/ValidationStack.java @@ -58,12 +58,6 @@ @ParametersAreNonnullByDefault final class ValidationStack { - /* - * Sentinel which is always the first element of the stack; we use it in - * order to simplify the pop code. - */ - private static final Element NULL_ELEMENT = new Element(null, null); - /* * Queue of visited contexts */ diff --git a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/CallbackValidatorTest.java b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/CallbackValidatorTest.java index d5d936e94..92ada83b5 100644 --- a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/CallbackValidatorTest.java +++ b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/CallbackValidatorTest.java @@ -21,7 +21,7 @@ import static com.github.fge.jsonschema.TestUtils.anyReport; import static com.github.fge.jsonschema.TestUtils.onlyOnce; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; @@ -247,6 +247,7 @@ private DummyProcessor(final WantedState wanted1, } @Override + @SuppressWarnings("ReferenceEquality") public FullData process(final ProcessingReport report, final FullData input) throws ProcessingException