OpenPojo / openpojo

POJO Testing & Identity Management Made Trivial
http://openpojo.com
Apache License 2.0
156 stars 40 forks source link

ReflectionException when running tests several times #95

Closed Yky closed 6 years ago

Yky commented 7 years ago

If I run my tests several times without changing code I sometimes get the following Exception:

com.openpojo.reflection.exception.ReflectionException: Field name =[m] matches registered prefix=[m], if stripped, empty string will result
    at com.openpojo.reflection.exception.ReflectionException.getInstance(ReflectionException.java:38)
    at com.openpojo.reflection.utils.AttributeHelper.stripPrefix(AttributeHelper.java:84)
    at com.openpojo.reflection.utils.AttributeHelper.getAttributeName(AttributeHelper.java:77)
    at com.openpojo.reflection.impl.PojoMethodFactory.generateGetMethodNames(PojoMethodFactory.java:122)
    at com.openpojo.reflection.impl.PojoMethodFactory.getFieldGetter(PojoMethodFactory.java:90)
    at com.openpojo.reflection.impl.PojoFieldImpl.<init>(PojoFieldImpl.java:53)
    at com.openpojo.reflection.impl.PojoFieldFactory.getPojoFields(PojoFieldFactory.java:44)
    at com.openpojo.reflection.service.impl.DefaultPojoClassLookupService.getPojoClass(DefaultPojoClassLookupService.java:64)
    at com.openpojo.reflection.impl.PojoClassFactory.getPojoClass(PojoClassFactory.java:42)
    at com.openpojo.random.collection.set.ConcurrentSkipListSetRandomGenerator.getBasicInstance(ConcurrentSkipListSetRandomGenerator.java:52)
    at com.openpojo.random.collection.util.BaseCollectionRandomGenerator.doGenerate(BaseCollectionRandomGenerator.java:33)
    at com.openpojo.random.collection.util.BaseCollectionRandomGenerator.doGenerate(BaseCollectionRandomGenerator.java:30)
    at com.openpojo.random.service.impl.RandomGeneratorAdapter.doGenerate(RandomGeneratorAdapter.java:55)
    at com.openpojo.random.RandomFactory.getRandomValue(RandomFactory.java:99)
    at com.openpojo.random.RandomFactory.getRandomValue(RandomFactory.java:107)
    at com.openpojo.random.map.util.MapHelper.buildMap(MapHelper.java:50)
    at com.openpojo.random.map.util.BaseMapRandomGenerator.doGenerate(BaseMapRandomGenerator.java:38)
    at com.openpojo.random.map.util.BaseMapRandomGenerator.doGenerate(BaseMapRandomGenerator.java:30)
    at com.openpojo.random.RandomFactory.getRandomValue(RandomFactory.java:111)
    at com.openpojo.validation.test.impl.SetterTester.run(SetterTester.java:43)
    at com.openpojo.validation.utils.ValidationHelper.runValidation(ValidationHelper.java:101)
    at com.openpojo.validation.impl.DefaultValidator.validate(DefaultValidator.java:46)
Yky commented 7 years ago

Ignore the commit on my fork, I overlooked something.

The cause of the problem seems to be ConcurrentSkipListSet that has an instance variable named "m". This is causing a conflict when checking for a registered field prefix m. I wonder why the field names of a generated class are checked? I would assume only non-openpojo and non-openpojo-generated code should be checked?

Yky commented 7 years ago

I still get this error with 0.8.5

oshoukry commented 7 years ago

Could you please submit a code sample demonstrating the error?

Yky commented 7 years ago

Sure.

The DTO to be tested: https://gist.github.com/Yky/2e22f0e00109edc13dc3740808a35937

The test for the DTO: https://gist.github.com/Yky/a334568ea379854558ef376aeea4c3bd

Since there is a random element in OpenPojo you might need to run the test several times to get the exception with the ConcurrentSkipListSet.

Yky commented 6 years ago

@oshoukry Have you been able to reproduce this error with my samples?

oshoukry commented 6 years ago

I am able to generate the error. Thank you for reporting, update soon.

oshoukry commented 6 years ago

Fixed in version 0.8.10.