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

NPE throw when applying projections in findAndModify #35

Closed
jeffmay opened this issue Apr 29, 2014 · 5 comments
Closed

NPE throw when applying projections in findAndModify #35

jeffmay opened this issue Apr 29, 2014 · 5 comments
Labels
Milestone

Comments

@jeffmay
Copy link

jeffmay commented Apr 29, 2014

when:

  • collection.size = 1
  • objectsToSearch.size = 1
  • update = DBObject with modifiers
  • upsert = false
  • returnNew = true or false
  • remove = false

it gets to applyProjections with beforeObject == null and afterObject == null, and applyProjections can't handle a null. I am expecting to get the item I saved back from the database.

Both my unit tests with returnNew == true and returnNew == false are failing with an exception, rather than receiving a null.

@twillouer
Copy link
Collaborator

Thanks for the report.

Can you me the stacktrace ?
Le 29 avr. 2014 02:46, "Jeff May" notifications@github.com a écrit :

when:

  • collection.size = 1
  • objectsToSearch.size = 1
  • update = modifier
  • upsert = false
  • returnNew = true or false
  • remove = false

it gets to applyProjections with beforeObject == null and afterObject ==
null, and applyProjections can't handle a null. I am expecting to get the
item I saved back from the database.

Both my unit tests with returnNew == true and returnNew == false are
failing with an exception, rather than receiving a null.


Reply to this email directly or view it on GitHubhttps://github.com//issues/35
.

@jeffmay
Copy link
Author

jeffmay commented Apr 29, 2014

I figured out my issue. I was asking for a field that wasn't in the projected results. I was both asking for the wrong field, and the projection was an empty object. My issue is resolved, but I feel like this should throw a different exception.

Collection = test_eligibilityRecord_IfONHbKqHd34Operation = findAndModifyProjection = "{ }"Query = "{ "id" : "cGuqW6B4MnNo" , "partner" : "partner"}"Remove = "false"ReturnNew = "false"Sort = "{ }"Update = "{ "$set" : { "userId" : "535ff53dc0263abbaef86173"}}"Upsert = "false"
com.careverge.mongo.CareMongoException: Collection = test_eligibilityRecord_IfONHbKqHd34Operation = findAndModifyProjection = "{ }"Query = "{ "id" : "cGuqW6B4MnNo" , "partner" : "partner"}"Remove = "false"ReturnNew = "false"Sort = "{ }"Update = "{ "$set" : { "userId" : "535ff53dc0263abbaef86173"}}"Upsert = "false"
    at com.careverge.mongo.CoreCareMongoCollection.findAndModify(CoreCareMongoCollection.scala:70)
    at com.careverge.mongo.collection.eligibility.EligibilityRecordCollection.updateUserId(EligibilityRecordCollection.scala:70)
    at com.careverge.mongo.collection.eligibility.EligibilityRecordCollectionSpec$$anonfun$6.apply(EligibilityRecordCollectionSpec.scala:127)
    at com.careverge.mongo.collection.eligibility.EligibilityRecordCollectionSpec$$anonfun$6.apply(EligibilityRecordCollectionSpec.scala:110)
    at org.scalatest.fixture.Suite$TestFunAndConfigMap$$anonfun$apply$1.apply(Suite.scala:155)
    at org.scalatest.fixture.Suite$TestFunAndConfigMap$$anonfun$apply$1.apply(Suite.scala:155)
    at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
    at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
    at org.scalatest.fixture.Suite$TestFunAndConfigMap.apply(Suite.scala:155)
    at com.careverge.mongo.collection.eligibility.EligibilityRecordCollectionSpec.withFixture(EligibilityRecordCollectionSpec.scala:25)
    at org.scalatest.fixture.FlatSpecLike$class.invokeWithFixture$1(FlatSpecLike.scala:2072)
    at org.scalatest.fixture.FlatSpecLike$$anonfun$runTest$1.apply(FlatSpecLike.scala:2083)
    at org.scalatest.fixture.FlatSpecLike$$anonfun$runTest$1.apply(FlatSpecLike.scala:2083)
    at org.scalatest.SuperEngine.runTestImpl(Engine.scala:306)
    at org.scalatest.fixture.FlatSpecLike$class.runTest(FlatSpecLike.scala:2083)
    at org.scalatest.fixture.FlatSpec.runTest(FlatSpec.scala:234)
    at org.scalatest.fixture.FlatSpecLike$$anonfun$runTests$1.apply(FlatSpecLike.scala:2126)
    at org.scalatest.fixture.FlatSpecLike$$anonfun$runTests$1.apply(FlatSpecLike.scala:2126)
    at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:413)
    at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:401)
    at scala.collection.immutable.List.foreach(List.scala:318)
    at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
    at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:390)
    at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:427)
    at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:401)
    at scala.collection.immutable.List.foreach(List.scala:318)
    at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
    at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:396)
    at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:483)
    at org.scalatest.fixture.FlatSpecLike$class.runTests(FlatSpecLike.scala:2126)
    at org.scalatest.fixture.FlatSpec.runTests(FlatSpec.scala:234)
    at org.scalatest.Suite$class.run(Suite.scala:1423)
    at org.scalatest.fixture.FlatSpec.org$scalatest$fixture$FlatSpecLike$$super$run(FlatSpec.scala:234)
    at org.scalatest.fixture.FlatSpecLike$$anonfun$run$1.apply(FlatSpecLike.scala:2148)
    at org.scalatest.fixture.FlatSpecLike$$anonfun$run$1.apply(FlatSpecLike.scala:2148)
    at org.scalatest.SuperEngine.runImpl(Engine.scala:545)
    at org.scalatest.fixture.FlatSpecLike$class.run(FlatSpecLike.scala:2148)
    at org.scalatest.fixture.FlatSpec.run(FlatSpec.scala:234)
    at org.scalatest.tools.SuiteRunner.run(SuiteRunner.scala:55)
    at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:2563)
    at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:2557)
    at scala.collection.immutable.List.foreach(List.scala:318)
    at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:2557)
    at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1044)
    at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1043)
    at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:2722)
    at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:1043)
    at org.scalatest.tools.Runner$.run(Runner.scala:883)
    at org.scalatest.tools.Runner.run(Runner.scala)
    at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:144)
    at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:35)
Caused by: java.lang.NullPointerException
    at com.mongodb.FongoDBCollection.applyProjections(FongoDBCollection.java:582)
    at com.mongodb.FongoDBCollection.findAndModify(FongoDBCollection.java:693)
    at com.mongodb.casbah.MongoCollectionBase$class.findAndModify(MongoCollection.scala:272)
    at com.mongodb.casbah.MongoCollection.findAndModify(MongoCollection.scala:866)
    at com.careverge.mongo.CoreCareMongoCollection.findAndModify(CoreCareMongoCollection.scala:64)
    ... 50 more

@twillouer
Copy link
Collaborator

You'Re totaly right.

Witch version of fongo do you use ?
Le 29 avr. 2014 20:54, "Jeff May" notifications@github.com a écrit :

I figured out my issue. I was asking for a field that wasn't in the
projected results. I was both asking for the wrong field, and the
projection was an empty object. My issue is resolved, but I feel like this
should throw a different exception.

Collection = test_eligibilityRecord_IfONHbKqHd34Operation = findAndModifyProjection = "{ }"Query = "{ "id" : "cGuqW6B4MnNo" , "partner" : "partner"}"Remove = "false"ReturnNew = "false"Sort = "{ }"Update = "{ "$set" : { "userId" : "535ff53dc0263abbaef86173"}}"Upsert = "false"
com.careverge.mongo.CareMongoException: Collection = test_eligibilityRecord_IfONHbKqHd34Operation = findAndModifyProjection = "{ }"Query = "{ "id" : "cGuqW6B4MnNo" , "partner" : "partner"}"Remove = "false"ReturnNew = "false"Sort = "{ }"Update = "{ "$set" : { "userId" : "535ff53dc0263abbaef86173"}}"Upsert = "false"
at com.careverge.mongo.CoreCareMongoCollection.findAndModify(CoreCareMongoCollection.scala:70)
at com.careverge.mongo.collection.eligibility.EligibilityRecordCollection.updateUserId(EligibilityRecordCollection.scala:70)
at com.careverge.mongo.collection.eligibility.EligibilityRecordCollectionSpec$$anonfun$6.apply(EligibilityRecordCollectionSpec.scala:127)
at com.careverge.mongo.collection.eligibility.EligibilityRecordCollectionSpec$$anonfun$6.apply(EligibilityRecordCollectionSpec.scala:110)
at org.scalatest.fixture.Suite$TestFunAndConfigMap$$anonfun$apply$1.apply(Suite.scala:155)
at org.scalatest.fixture.Suite$TestFunAndConfigMap$$anonfun$apply$1.apply(Suite.scala:155)
at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
at org.scalatest.fixture.Suite$TestFunAndConfigMap.apply(Suite.scala:155)
at com.careverge.mongo.collection.eligibility.EligibilityRecordCollectionSpec.withFixture(EligibilityRecordCollectionSpec.scala:25)
at org.scalatest.fixture.FlatSpecLike$class.invokeWithFixture$1(FlatSpecLike.scala:2072)
at org.scalatest.fixture.FlatSpecLike$$anonfun$runTest$1.apply(FlatSpecLike.scala:2083)
at org.scalatest.fixture.FlatSpecLike$$anonfun$runTest$1.apply(FlatSpecLike.scala:2083)
at org.scalatest.SuperEngine.runTestImpl(Engine.scala:306)
at org.scalatest.fixture.FlatSpecLike$class.runTest(FlatSpecLike.scala:2083)
at org.scalatest.fixture.FlatSpec.runTest(FlatSpec.scala:234)
at org.scalatest.fixture.FlatSpecLike$$anonfun$runTests$1.apply(FlatSpecLike.scala:2126)
at org.scalatest.fixture.FlatSpecLike$$anonfun$runTests$1.apply(FlatSpecLike.scala:2126)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:413)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:401)
at scala.collection.immutable.List.foreach(List.scala:318)
at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:390)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:427)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:401)
at scala.collection.immutable.List.foreach(List.scala:318)
at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:396)
at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:483)
at org.scalatest.fixture.FlatSpecLike$class.runTests(FlatSpecLike.scala:2126)
at org.scalatest.fixture.FlatSpec.runTests(FlatSpec.scala:234)
at org.scalatest.Suite$class.run(Suite.scala:1423)
at org.scalatest.fixture.FlatSpec.org$scalatest$fixture$FlatSpecLike$$super$run(FlatSpec.scala:234)
at org.scalatest.fixture.FlatSpecLike$$anonfun$run$1.apply(FlatSpecLike.scala:2148)
at org.scalatest.fixture.FlatSpecLike$$anonfun$run$1.apply(FlatSpecLike.scala:2148)
at org.scalatest.SuperEngine.runImpl(Engine.scala:545)
at org.scalatest.fixture.FlatSpecLike$class.run(FlatSpecLike.scala:2148)
at org.scalatest.fixture.FlatSpec.run(FlatSpec.scala:234)
at org.scalatest.tools.SuiteRunner.run(SuiteRunner.scala:55)
at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:2563)
at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:2557)
at scala.collection.immutable.List.foreach(List.scala:318)
at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:2557)
at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1044)
at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1043)
at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:2722)
at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:1043)
at org.scalatest.tools.Runner$.run(Runner.scala:883)
at org.scalatest.tools.Runner.run(Runner.scala)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:144)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:35)
Caused by: java.lang.NullPointerException
at com.mongodb.FongoDBCollection.applyProjections(FongoDBCollection.java:582)
at com.mongodb.FongoDBCollection.findAndModify(FongoDBCollection.java:693)
at com.mongodb.casbah.MongoCollectionBase$class.findAndModify(MongoCollection.scala:272)
at com.mongodb.casbah.MongoCollection.findAndModify(MongoCollection.scala:866)
at com.careverge.mongo.CoreCareMongoCollection.findAndModify(CoreCareMongoCollection.scala:64)
... 50 more


Reply to this email directly or view it on GitHubhttps://github.com//issues/35#issuecomment-41717351
.

@jeffmay
Copy link
Author

jeffmay commented Apr 30, 2014

"com.github.fakemongo" % "fongo" % "1.3.6"

@twillouer
Copy link
Collaborator

Thanks, issue will be resolved in 1.4.6
Le 30 avr. 2014 16:22, "Jeff May" notifications@github.com a écrit :

"com.github.fakemongo" % "fongo" % "1.3.6"


Reply to this email directly or view it on GitHubhttps://github.com//issues/35#issuecomment-41801999
.

twillouer added a commit that referenced this issue May 5, 2014
@twillouer twillouer added this to the 1.5.0 milestone May 5, 2014
@twillouer twillouer added the bug label May 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants