Skip to content

Commit cf8b367

Browse files
committed
[JAVA-261]: GridFSInputFile.getMetaData() returns wrong value
1 parent 0322ed0 commit cf8b367

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/main/com/mongodb/gridfs/GridFSFile.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,25 @@ public Date getUploadDate(){
136136
* @return
137137
*/
138138
public List<String> getAliases(){
139-
return (List<String>)_metadata.get( "aliases" );
139+
return (List<String>)_extradata.get( "aliases" );
140140
}
141141

142142
/**
143143
* Gets the file metadata
144144
* @return
145145
*/
146146
public DBObject getMetaData(){
147-
return (DBObject)_metadata.get( "metadata" );
147+
return (DBObject)_extradata.get( "metadata" );
148148
}
149-
149+
150+
/**
151+
* Gets the file metadata
152+
* @return
153+
*/
154+
public void setMetaData(DBObject metadata){
155+
_extradata.put( "metadata", metadata );
156+
}
157+
150158
/**
151159
* Gets the observed MD5 during transfer
152160
* @return
@@ -177,7 +185,7 @@ else if ( key.equals( "uploadDate" ) )
177185
else if ( key.equals( "md5" ) )
178186
_md5 = (String)v;
179187
else
180-
_metadata.put( key , v );
188+
_extradata.put( key , v );
181189
return v;
182190
}
183191

@@ -198,7 +206,7 @@ else if ( key.equals( "uploadDate" ) )
198206
return _uploadDate;
199207
else if ( key.equals( "md5" ) )
200208
return _md5;
201-
return _metadata.get( key );
209+
return _extradata.get( key );
202210
}
203211

204212
public void putAll( BSONObject o ){
@@ -232,7 +240,7 @@ public boolean containsField(String s){
232240
public Set<String> keySet(){
233241
Set<String> keys = new HashSet();
234242
keys.addAll(VALID_FIELDS);
235-
keys.addAll(_metadata.keySet());
243+
keys.addAll(_extradata.keySet());
236244
return keys;
237245
}
238246

@@ -270,7 +278,7 @@ protected void setGridFS( GridFS fs ){
270278
long _chunkSize;
271279
Date _uploadDate;
272280
List<String> _aliases;
273-
DBObject _metadata = new BasicDBObject();
281+
DBObject _extradata = new BasicDBObject();
274282
String _md5;
275283

276284
final static Set<String> VALID_FIELDS = Collections.unmodifiableSet( new HashSet( Arrays.asList( new String[]{

src/main/com/mongodb/gridfs/GridFSInputFile.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,6 @@ public class GridFSInputFile extends GridFSFile {
8888
this( fs , null , null );
8989
}
9090

91-
@Override
92-
public DBObject getMetaData() {
93-
if ( _metadata == null ) {
94-
_metadata = new BasicDBObject();
95-
}
96-
return _metadata;
97-
}
98-
9991
/**
10092
* Sets the file name on the GridFS entry.
10193
*

0 commit comments

Comments
 (0)