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

Minor/Usability: misleading exception if schema refers to nonexistent property #13

Open
mrprescott opened this issue May 7, 2014 · 3 comments

Comments

@mrprescott
Copy link

I deleted an attribute from the class I'm storing in a KV store, and forgot to delete it from the schema definition. When I call kvStore.create(), I get the exception shown below.

This is a minor problem, but could be a stumbling block if someone inadvertently typos in a long property name and doesn't see it, and spends time trying to figure out why it's null.

org.skife.jdbi.v2.exceptions.CallbackFailedException: io.kazuki.v0.store.schema.model.TransformException: attribute must not be null: blobId
at org.skife.jdbi.v2.DBI.withHandle(DBI.java:276)
at org.skife.jdbi.v2.DBI.inTransaction(DBI.java:298)
at io.kazuki.v0.store.keyvalue.KeyValueStoreJdbiBaseImpl.create(KeyValueStoreJdbiBaseImpl.java:178)
at io.kazuki.v0.store.keyvalue.KeyValueStoreJdbiBaseImpl.create(KeyValueStoreJdbiBaseImpl.java:152)
at org.sonatype.nexus.blobstore.file.kazuki.KazukiBlobMetadataStore.add(KazukiBlobMetadataStore.java:143)
at org.sonatype.nexus.blobstore.file.FileBlobStore.create(FileBlobStore.java:84)
at org.sonatype.nexus.blobstore.file.FileBlobStoreIT.basicSmokeTest(FileBlobStoreIT.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: io.kazuki.v0.store.schema.model.TransformException: attribute must not be null: blobId
at io.kazuki.v0.internal.v2schema.compact.FieldTransform.pack(FieldTransform.java:72)
at io.kazuki.v0.store.keyvalue.KeyValueStoreJdbiBaseImpl$3.inTransaction(KeyValueStoreJdbiBaseImpl.java:187)
at io.kazuki.v0.store.keyvalue.KeyValueStoreJdbiBaseImpl$3.inTransaction(KeyValueStoreJdbiBaseImpl.java:178)
at org.skife.jdbi.v2.tweak.transactions.LocalTransactionHandler.inTransaction(LocalTransactionHandler.java:192)
at org.skife.jdbi.v2.BasicHandle.inTransaction(BasicHandle.java:306)
at org.skife.jdbi.v2.DBI$4.withHandle(DBI.java:301)
at org.skife.jdbi.v2.DBI.withHandle(DBI.java:273)
... 36 more

@sunnygleason
Copy link
Contributor

this will be helped by 2 things:

  1. I'll fix the error message as you request
  2. in the upcoming schema migration release series, we'll be able to detect a schema version mismatch between the app & datastore

@mrprescott
Copy link
Author

Nice.

@mrprescott
Copy link
Author

I made the same mistake again! But in 0.5.11, this same situation seems to thrown an NPE, obscuring the message completely. The CallbackFailedException (wrapping TransformException) doesn't percolate out, as the error-reporting code NPEs.
java.lang.NullPointerException
at io.kazuki.v0.store.keyvalue.KeyValueStoreJdbiBaseImpl.create(KeyValueStoreJdbiBaseImpl.java:227)
at io.kazuki.v0.store.keyvalue.KeyValueStoreJdbiBaseImpl.create(KeyValueStoreJdbiBaseImpl.java:163)

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