@@ -54,7 +54,9 @@ public final class Instrumentation {
54
54
public static Tuple <Boolean , Iterable <LogEntry >> populateInstrumentationInfo (
55
55
Iterable <LogEntry > logEntries ) {
56
56
boolean isWritten = setInstrumentationStatus (true );
57
- if (isWritten ) return Tuple .of (false , logEntries );
57
+ if (isWritten ) {
58
+ return Tuple .of (false , logEntries );
59
+ }
58
60
List <LogEntry > entries = new ArrayList <>();
59
61
60
62
for (LogEntry logEntry : logEntries ) {
@@ -97,7 +99,9 @@ public static Tuple<Boolean, Iterable<LogEntry>> populateInstrumentationInfo(
97
99
* true
98
100
*/
99
101
public static WriteOption @ Nullable [] addPartialSuccessOption (WriteOption [] options ) {
100
- if (options == null ) return options ;
102
+ if (options == null ) {
103
+ return options ;
104
+ }
101
105
List <WriteOption > writeOptions = new ArrayList <>();
102
106
Collections .addAll (writeOptions , options );
103
107
// Make sure we remove all partial success flags if any exist
@@ -146,8 +150,9 @@ private static LogEntry createDiagnosticEntry(
146
150
147
151
private static ListValue generateLibrariesList (
148
152
String libraryName , String libraryVersion , ListValue existingLibraryList ) {
149
- if (Strings .isNullOrEmpty (libraryName ) || !libraryName .startsWith (JAVA_LIBRARY_NAME_PREFIX ))
153
+ if (Strings .isNullOrEmpty (libraryName ) || !libraryName .startsWith (JAVA_LIBRARY_NAME_PREFIX )) {
150
154
libraryName = JAVA_LIBRARY_NAME_PREFIX ;
155
+ }
151
156
if (Strings .isNullOrEmpty (libraryVersion )) {
152
157
libraryVersion = getLibraryVersion (Instrumentation .class );
153
158
}
@@ -161,14 +166,21 @@ private static ListValue generateLibrariesList(
161
166
try {
162
167
String name =
163
168
val .getStructValue ().getFieldsOrThrow (INSTRUMENTATION_NAME_KEY ).getStringValue ();
164
- if (Strings .isNullOrEmpty (name ) || !name .startsWith (JAVA_LIBRARY_NAME_PREFIX )) continue ;
169
+ if (Strings .isNullOrEmpty (name ) || !name .startsWith (JAVA_LIBRARY_NAME_PREFIX )) {
170
+ continue ;
171
+ }
165
172
String version =
166
173
val .getStructValue ().getFieldsOrThrow (INSTRUMENTATION_VERSION_KEY ).getStringValue ();
167
- if (Strings .isNullOrEmpty (version )) continue ;
174
+ if (Strings .isNullOrEmpty (version )) {
175
+ continue ;
176
+ }
168
177
libraryList .addValues (
169
178
Value .newBuilder ().setStructValue (createInfoStruct (name , version )).build ());
170
- if (libraryList .getValuesCount () == MAX_DIAGNOSTIC_ENTIES ) break ;
179
+ if (libraryList .getValuesCount () == MAX_DIAGNOSTIC_ENTIES ) {
180
+ break ;
181
+ }
171
182
} catch (RuntimeException ex ) {
183
+ System .err .println ("ERROR: unexpected exception in generateLibrariesList: " + ex );
172
184
}
173
185
}
174
186
}
@@ -194,7 +206,9 @@ private static Struct createInfoStruct(String libraryName, String libraryVersion
194
206
* @return The value of the flag before it was set.
195
207
*/
196
208
static boolean setInstrumentationStatus (boolean value ) {
197
- if (instrumentationAdded == value ) return instrumentationAdded ;
209
+ if (instrumentationAdded == value ) {
210
+ return instrumentationAdded ;
211
+ }
198
212
synchronized (instrumentationLock ) {
199
213
boolean current = instrumentationAdded ;
200
214
instrumentationAdded = value ;
@@ -211,12 +225,16 @@ static boolean setInstrumentationStatus(boolean value) {
211
225
*/
212
226
public static String getLibraryVersion (Class <?> libraryClass ) {
213
227
String libraryVersion = GaxProperties .getLibraryVersion (libraryClass );
214
- if (Strings .isNullOrEmpty (libraryVersion )) libraryVersion = DEFAULT_INSTRUMENTATION_VERSION ;
228
+ if (Strings .isNullOrEmpty (libraryVersion )) {
229
+ libraryVersion = DEFAULT_INSTRUMENTATION_VERSION ;
230
+ }
215
231
return libraryVersion ;
216
232
}
217
233
218
234
private static String truncateValue (String value ) {
219
- if (Strings .isNullOrEmpty (value ) || value .length () < MAX_DIAGNOSTIC_VALUE_LENGTH ) return value ;
235
+ if (Strings .isNullOrEmpty (value ) || value .length () < MAX_DIAGNOSTIC_VALUE_LENGTH ) {
236
+ return value ;
237
+ }
220
238
return value .substring (0 , MAX_DIAGNOSTIC_VALUE_LENGTH ) + "*" ;
221
239
}
222
240
0 commit comments