@@ -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 }
0 commit comments