[JAVA-442] Index on chunks collection not getting created when adding a file via GridFS Created: 03/Oct/11  Updated: 15/May/12  Resolved: 15/May/12

Status: Closed
Project: Java Driver
Component/s: API
Affects Version/s: 2.6.5
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Adam Burnett Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OSX, mongod 2.0.0


Attachments: File gridfs-test.tgz    

 Description   

Saving a file using the GridFS API is not creating the required index in the chunks collection for files_id and n. The result is that after saving a file calling GridFSInputFile.validate() will throw a NullPointerException. Attached is a maven based project to reproduce. Run with: mvn test

Current workaround is to create the index per the spec



 Comments   
Comment by Jeffrey Yemin [ 15/May/12 ]

The index is created in the GridFS constructor. The provided test drops the collection after calling the constructor, so that's why you lose the index. Move the call to GridFS constructor to the end of the setup method and the test passes.

Comment by Adam Burnett [ 03/Oct/11 ]

Current test output:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running gridfs.TestGridFS
********* Connecting to localhost/test-gridfs
********* Mongo Client 2.6
********* Connected to mongo 2.0.0
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.234 sec <<< FAILURE!
 
Results :
 
Failed tests: 
  testVerifyFile(gridfs.TestGridFS)
 
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
 
-------------------------------------------------------------------------------
Test set: gridfs.TestGridFS
-------------------------------------------------------------------------------
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.235 sec <<< FAILURE!
testVerifyFile(gridfs.TestGridFS)  Time elapsed: 0.087 sec  <<< FAILURE!
junit.framework.AssertionFailedError: Index on files, n does not exist
...

Generated at Thu Feb 08 08:52:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.