Skip to content

Commit 1943db5

Browse files
Gabor Botasteveloughran
authored andcommitted
HADOOP-16237. Fix new findbugs issues after updating guava to 27.0-jre.
Author: Gabor Bota <[email protected]>
1 parent 2382f63 commit 1943db5

File tree

6 files changed

+71
-13
lines changed

6 files changed

+71
-13
lines changed

hadoop-common-project/hadoop-kms/dev-support/findbugsExcludeFile.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
limitations under the License.
1616
-->
1717
<FindBugsFilter>
18+
19+
<!-- The called method signature is isNullOrEmpty(@Nullable String string) in guava 27, so this should be ignored. -->
20+
<Match>
21+
<Class name="org.apache.hadoop.crypto.key.kms.server.KMSAudit"/>
22+
<Method name="op" />
23+
<Bug pattern="NP_NULL_PARAM_DEREF"/>
24+
</Match>
25+
1826
<!--
1927
Findbug is complaining about System.out being NULL
2028
-->

hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,4 +660,41 @@
660660
<Bug pattern="EI_EXPOSE_REP" />
661661
</Match>
662662

663+
<!-- The called method signature is String emptyToNull(@Nullable String string) in guava 27, so this should be ignored -->
664+
<Match>
665+
<Class name="org.apache.hadoop.yarn.server.nodemanager.NodeHealthCheckerService"/>
666+
<Method name="getHealthReport" />
667+
<Bug pattern="NP_NULL_PARAM_DEREF"/>
668+
</Match>
669+
670+
<!-- The variable is not used, but it's defined for the document model. -->
671+
<Match>
672+
<Class name="org.apache.hadoop.yarn.server.timelineservice.documentstore.collection.document.entity.TimelineEventSubDoc"/>
673+
<Method name="setValid" />
674+
<Bug pattern="URF_UNREAD_FIELD"/>
675+
</Match>
676+
677+
<!-- The variable is not used, but it's defined for the document model. -->
678+
<Match>
679+
<Class name="org.apache.hadoop.yarn.server.timelineservice.documentstore.collection.document.entity.TimelineMetricSubDoc"/>
680+
<Method name="setValid" />
681+
<Bug pattern="URF_UNREAD_FIELD"/>
682+
</Match>
683+
684+
<!-- The called method signature is public boolean set(@Nullable V value) in guava 27, so this should be ignored -->
685+
<Match>
686+
<Class name="org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore$UpdateAppTransition"/>
687+
<Method name="transition" />
688+
<Local name="result" />
689+
<Bug pattern="NP_NONNULL_PARAM_VIOLATION"/>
690+
</Match>
691+
692+
<!-- The called method signature is public boolean set(@Nullable V value) in guava 27, so this should be ignored -->
693+
<Match>
694+
<Class name="org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler"/>
695+
<Method name="updateApplicationPriority" />
696+
<Local name="result" />
697+
<Bug pattern="NP_NONNULL_PARAM_VIOLATION"/>
698+
</Match>
699+
663700
</FindBugsFilter>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/collection/document/entity/TimelineEntityDocument.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,18 @@ public Map<String, Set<TimelineMetricSubDoc>> getMetrics() {
138138
}
139139

140140
public void setMetrics(Map<String, Set<TimelineMetricSubDoc>> metrics) {
141-
for (String metricId : metrics.keySet()) {
142-
for(TimelineMetricSubDoc metricSubDoc : metrics.get(metricId)) {
141+
for (Map.Entry<String, Set<TimelineMetricSubDoc>> metricEntry :
142+
metrics.entrySet()) {
143+
final String metricId = metricEntry.getKey();
144+
final Set<TimelineMetricSubDoc> metricValue = metricEntry.getValue();
145+
146+
for(TimelineMetricSubDoc metricSubDoc : metricValue) {
143147
timelineEntity.addMetric(metricSubDoc.fetchTimelineMetric());
144148
}
145149
if (this.metrics.containsKey(metricId)) {
146-
this.metrics.get(metricId).addAll(metrics.get(metricId));
150+
this.metrics.get(metricId).addAll(metricValue);
147151
} else {
148-
this.metrics.put(metricId, new HashSet<>(metrics.get(metricId)));
152+
this.metrics.put(metricId, new HashSet<>(metricValue));
149153
}
150154
}
151155
}
@@ -155,14 +159,18 @@ public Map<String, Set<TimelineEventSubDoc>> getEvents() {
155159
}
156160

157161
public void setEvents(Map<String, Set<TimelineEventSubDoc>> events) {
158-
for (String eventId : events.keySet()) {
159-
for(TimelineEventSubDoc eventSubDoc: events.get(eventId)) {
162+
for (Map.Entry<String, Set<TimelineEventSubDoc>> eventEntry :
163+
events.entrySet()) {
164+
final String eventId = eventEntry.getKey();
165+
final Set<TimelineEventSubDoc> eventValue = eventEntry.getValue();
166+
167+
for(TimelineEventSubDoc eventSubDoc : eventValue) {
160168
timelineEntity.addEvent(eventSubDoc.fetchTimelineEvent());
161169
}
162170
if (this.events.containsKey(eventId)) {
163171
this.events.get(eventId).addAll(events.get(eventId));
164172
} else {
165-
this.events.put(eventId, new HashSet<>(events.get(eventId)));
173+
this.events.put(eventId, new HashSet<>(eventValue));
166174
}
167175
}
168176
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/collection/document/flowrun/FlowRunDocument.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,14 @@ public void merge(FlowRunDocument flowRunDoc) {
9797

9898
private void aggregateMetrics(
9999
Map<String, TimelineMetricSubDoc> metricSubDocMap) {
100-
for(String metricId : metricSubDocMap.keySet()) {
100+
for(Map.Entry<String, TimelineMetricSubDoc> metricEntry :
101+
metricSubDocMap.entrySet()) {
102+
final String metricId = metricEntry.getKey();
103+
final TimelineMetricSubDoc metricValue = metricEntry.getValue();
104+
101105
if (this.metrics.containsKey(metricId)) {
102106
TimelineMetric incomingMetric =
103-
metricSubDocMap.get(metricId).fetchTimelineMetric();
107+
metricValue.fetchTimelineMetric();
104108
TimelineMetric baseMetric =
105109
this.metrics.get(metricId).fetchTimelineMetric();
106110
if (incomingMetric.getValues().size() > 0) {
@@ -111,7 +115,7 @@ private void aggregateMetrics(
111115
baseMetric.getId());
112116
}
113117
} else {
114-
this.metrics.put(metricId, metricSubDocMap.get(metricId));
118+
this.metrics.put(metricId, metricValue);
115119
}
116120
}
117121
}
@@ -135,7 +139,8 @@ private TimelineMetric aggregate(TimelineMetric incomingMetric,
135139
baseMetric = TimelineMetricOperation.REPLACE
136140
.aggregate(incomingMetric, baseMetric, null);
137141
default:
138-
//NoOP
142+
LOG.warn("Unknown TimelineMetricOperation: {}",
143+
baseMetric.getRealtimeAggregationOp());
139144
}
140145
return baseMetric;
141146
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/reader/cosmosdb/CosmosDBDocumentStoreReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class CosmosDBDocumentStoreReader<TimelineDoc extends TimelineDocument>
4949
.getLogger(CosmosDBDocumentStoreReader.class);
5050
private static final int DEFAULT_DOCUMENTS_SIZE = 1;
5151

52-
private static DocumentClient client;
52+
private static volatile DocumentClient client;
5353
private final String databaseName;
5454
private final static String COLLECTION_LINK = "/dbs/%s/colls/%s";
5555
private final static String SELECT_TOP_FROM_COLLECTION = "SELECT TOP %d * " +

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/writer/cosmosdb/CosmosDBDocumentStoreWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class CosmosDBDocumentStoreWriter<TimelineDoc extends TimelineDocument>
5151
private static final Logger LOG = LoggerFactory
5252
.getLogger(CosmosDBDocumentStoreWriter.class);
5353

54-
private static DocumentClient client;
54+
private static volatile DocumentClient client;
5555
private final String databaseName;
5656
private static final PerNodeAggTimelineCollectorMetrics METRICS =
5757
PerNodeAggTimelineCollectorMetrics.getInstance();

0 commit comments

Comments
 (0)