Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bfef3d1

Browse filesBrowse files
bpcreechBen Creech
andauthored
feat: Apply Google style recommendations (#1057)
Co-authored-by: Ben Creech <bpcreech@google.com>
1 parent ca095f0 commit bfef3d1
Copy full SHA for bfef3d1
Expand file treeCollapse file tree

14 files changed

+436
-399
lines changed

‎google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java

Copy file name to clipboardExpand all lines: google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java
+27-9Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ public final class Instrumentation {
5454
public static Tuple<Boolean, Iterable<LogEntry>> populateInstrumentationInfo(
5555
Iterable<LogEntry> logEntries) {
5656
boolean isWritten = setInstrumentationStatus(true);
57-
if (isWritten) return Tuple.of(false, logEntries);
57+
if (isWritten) {
58+
return Tuple.of(false, logEntries);
59+
}
5860
List<LogEntry> entries = new ArrayList<>();
5961

6062
for (LogEntry logEntry : logEntries) {
@@ -97,7 +99,9 @@ public static Tuple<Boolean, Iterable<LogEntry>> populateInstrumentationInfo(
9799
* true
98100
*/
99101
public static WriteOption @Nullable [] addPartialSuccessOption(WriteOption[] options) {
100-
if (options == null) return options;
102+
if (options == null) {
103+
return options;
104+
}
101105
List<WriteOption> writeOptions = new ArrayList<>();
102106
Collections.addAll(writeOptions, options);
103107
// Make sure we remove all partial success flags if any exist
@@ -146,8 +150,9 @@ private static LogEntry createDiagnosticEntry(
146150

147151
private static ListValue generateLibrariesList(
148152
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)) {
150154
libraryName = JAVA_LIBRARY_NAME_PREFIX;
155+
}
151156
if (Strings.isNullOrEmpty(libraryVersion)) {
152157
libraryVersion = getLibraryVersion(Instrumentation.class);
153158
}
@@ -161,14 +166,21 @@ private static ListValue generateLibrariesList(
161166
try {
162167
String name =
163168
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+
}
165172
String version =
166173
val.getStructValue().getFieldsOrThrow(INSTRUMENTATION_VERSION_KEY).getStringValue();
167-
if (Strings.isNullOrEmpty(version)) continue;
174+
if (Strings.isNullOrEmpty(version)) {
175+
continue;
176+
}
168177
libraryList.addValues(
169178
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+
}
171182
} catch (RuntimeException ex) {
183+
System.err.println("ERROR: unexpected exception in generateLibrariesList: " + ex);
172184
}
173185
}
174186
}
@@ -194,7 +206,9 @@ private static Struct createInfoStruct(String libraryName, String libraryVersion
194206
* @return The value of the flag before it was set.
195207
*/
196208
static boolean setInstrumentationStatus(boolean value) {
197-
if (instrumentationAdded == value) return instrumentationAdded;
209+
if (instrumentationAdded == value) {
210+
return instrumentationAdded;
211+
}
198212
synchronized (instrumentationLock) {
199213
boolean current = instrumentationAdded;
200214
instrumentationAdded = value;
@@ -211,12 +225,16 @@ static boolean setInstrumentationStatus(boolean value) {
211225
*/
212226
public static String getLibraryVersion(Class<?> libraryClass) {
213227
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+
}
215231
return libraryVersion;
216232
}
217233

218234
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+
}
220238
return value.substring(0, MAX_DIAGNOSTIC_VALUE_LENGTH) + "*";
221239
}
222240

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.