Skip to content

Commit 88b3240

Browse files
scotthernandezerh
authored andcommitted
formatting changes for previous commit
1 parent 0f93561 commit 88b3240

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

src/main/com/mongodb/WriteConcern.java

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,34 @@ public class WriteConcern {
5959
public final static WriteConcern FSYNC_SAFE = new WriteConcern(true);
6060
/** Exceptions are raised for network issues, and server errors; waits for at least 2 servers for the write operation*/
6161
public final static WriteConcern REPLICAS_SAFE = new WriteConcern(2);
62-
63-
//map of the constants from above for use by fromString
62+
63+
// map of the constants from above for use by fromString
6464
private static Map<String, WriteConcern> _namedConcerns = null;
6565

66-
/** Get the WriteConcern constants by name: NONE, NORMAL, SAFE, FSYNC_SAFE, REPLICA_SAFE. (matching is done case insensitively)*/
66+
/**
67+
* Get the WriteConcern constants by name: NONE, NORMAL, SAFE, FSYNC_SAFE,
68+
* REPLICA_SAFE. (matching is done case insensitively)
69+
*/
6770
public static WriteConcern valueOf(String name) {
68-
if (_namedConcerns == null) {
69-
HashMap<String, WriteConcern> newMap = new HashMap<String, WriteConcern>( 8 , 1 );
70-
for (Field f : WriteConcern.class.getFields())
71-
if (Modifier.isStatic( f.getModifiers() ) && f.getType().equals( WriteConcern.class )) {
72-
try {
73-
newMap.put( f.getName().toLowerCase(), (WriteConcern) f.get( null ) );
74-
} catch (Exception e) {
75-
throw new RuntimeException(e);
76-
}
77-
}
78-
79-
//Thought about doing a synchronize but this seems just as safe and I don't care about race conditions.
80-
_namedConcerns = newMap;
81-
}
82-
83-
return _namedConcerns.get(name.toLowerCase());
71+
if (_namedConcerns == null) {
72+
HashMap<String, WriteConcern> newMap = new HashMap<String, WriteConcern>( 8 , 1 );
73+
for (Field f : WriteConcern.class.getFields())
74+
if (Modifier.isStatic( f.getModifiers() ) && f.getType().equals( WriteConcern.class )) {
75+
try {
76+
newMap.put( f.getName().toLowerCase(), (WriteConcern) f.get( null ) );
77+
} catch (Exception e) {
78+
throw new RuntimeException( e );
79+
}
80+
}
81+
82+
// Thought about doing a synchronize but this seems just as safe and
83+
// I don't care about race conditions.
84+
_namedConcerns = newMap;
85+
}
86+
87+
return _namedConcerns.get( name.toLowerCase() );
8488
}
85-
89+
8690
public WriteConcern(){
8791
this(0);
8892
}

src/test/com/mongodb/JavaClientTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -625,15 +625,15 @@ public void testWriteResultMethodLevelWriteConcern(){
625625
}
626626

627627
@Test
628-
public void testWriteConcernValueOf(){
629-
WriteConcern wc1 = WriteConcern.NORMAL;
630-
WriteConcern wc2 = WriteConcern.valueOf( "normal" );
631-
WriteConcern wc3 = WriteConcern.valueOf( "NORMAL" );
632-
633-
assertEquals( wc1._w , wc2._w );
634-
assertEquals( wc1._w , wc3._w );
628+
public void testWriteConcernValueOf() {
629+
WriteConcern wc1 = WriteConcern.NORMAL;
630+
WriteConcern wc2 = WriteConcern.valueOf( "normal" );
631+
WriteConcern wc3 = WriteConcern.valueOf( "NORMAL" );
632+
633+
assertEquals( wc1._w, wc2._w );
634+
assertEquals( wc1._w, wc3._w );
635635
}
636-
636+
637637
@Test
638638
public void testFindAndModify(){
639639
DBCollection c = _db.getCollection( "findandmodify" );

0 commit comments

Comments
 (0)