Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaUtilRegexp does not implement equals #340

Closed
daniloarcidiacono opened this issue Nov 20, 2019 · 4 comments
Closed

JavaUtilRegexp does not implement equals #340

daniloarcidiacono opened this issue Nov 20, 2019 · 4 comments

Comments

@daniloarcidiacono
Copy link

daniloarcidiacono commented Nov 20, 2019

As per title, JavaUtilRegexp does not implement the equals() method.
Therefore, the following test fails:

@Test
public void equalsWhyYouNoWork() {
    // { "type": "string", "pattern": "^\\d*$" }
    final String rawSchema = "{ \"type\": \"string\", \"pattern\": \"^\\\\d*$\" }";
    final JSONObject objectSchema = new JSONObject(new JSONTokener(rawSchema));

    final SchemaLoader loader = SchemaLoader.builder().schemaJson(objectSchema).draftV7Support().build();
    final Schema schema = loader.load().build();

    final SchemaLoader loader2 = SchemaLoader.builder().schemaJson(objectSchema).draftV7Support().build();
    final Schema schema2 = loader2.load().build();

    assertEquals(schema, schema2);
}
@erosb
Copy link
Contributor

erosb commented Nov 20, 2019

Thanks for reporting the problem. It is now fixed in commit eb261ba8aa1a2137f7fd99a513fff3055a553db9 . In case you need the fix urgently, you can use it by setting the version number to the commit hash in your pom.xml (or whatevere you use).

@erosb erosb closed this as completed Nov 20, 2019
@daniloarcidiacono
Copy link
Author

I tried to use the new version, however the equality still does not work.

Explained here (https://stackoverflow.com/questions/10055034/java-comparing-two-pattern-objects), one should compare the pattern strings rather than the Pattern instances.

erosb added a commit that referenced this issue Dec 22, 2019
@erosb
Copy link
Contributor

erosb commented Dec 22, 2019

Hello @daniloarcidiacono , I released version 1.12.1 with a correct fix.

@daniloarcidiacono
Copy link
Author

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants