Skip to content

Commit a52ff39

Browse files
authored
Address sonarcloud issues (#71)
1 parent a38ad7e commit a52ff39

File tree

4 files changed

+7
-23
lines changed

4 files changed

+7
-23
lines changed

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/helper/JMXRequestSender.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,7 @@ protected String getFederationManagerObjectName(String sService)
584584
// look up the full name of the MBean in case we are in container
585585
Set<ObjectName> setResult = getCompleteObjectName(new ObjectName(sQuery));
586586

587-
for (Object oResult : setResult)
588-
{
589-
return oResult.toString();
590-
}
591-
return null;
587+
return setResult.isEmpty() ? null : setResult.iterator().next().toString();
592588
}
593589

594590

@@ -602,13 +598,7 @@ protected String getFederationManagerObjectName(String sService)
602598
*/
603599
private String getFirstResult(Set<ObjectName> setResult)
604600
{
605-
String sFQN = null;
606-
607-
if (!setResult.isEmpty())
608-
{
609-
sFQN = setResult.iterator().next().toString();
610-
}
611-
return sFQN;
601+
return setResult.isEmpty() ? null : setResult.iterator().next().toString();
612602
}
613603

614604
// ------ constants -----------------------------------------------------

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/panel/CoherenceHotCachePanel.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2023 Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -228,7 +228,7 @@ public void updateData()
228228
}
229229
if((int) entry.getValue().getColumn(HotCacheData.Max3)!=Integer.MIN_VALUE)
230230
{
231-
GraphHelper.addValuesToHotcacheGraph(m_hotcacheGraph3,(double) entry.getValue().getColumn(HotCacheData.Mean3), Integer.valueOf((int) entry.getValue().getColumn(HotCacheData.Max3)).longValue(), Integer.valueOf((int) entry.getValue().getColumn(HotCacheData.Min3)).longValue());
231+
GraphHelper.addValuesToHotcacheGraph(m_hotcacheGraph3,(double) entry.getValue().getColumn(HotCacheData.Mean3), (long) entry.getValue().getColumn(HotCacheData.Max3), (long) entry.getValue().getColumn(HotCacheData.Min3));
232232
}
233233
if((long) entry.getValue().getColumn(HotCacheData.Max4)!=Long.MIN_VALUE)
234234
{
@@ -244,7 +244,7 @@ public void updateData()
244244
}
245245
if((int) entry.getValue().getColumn(HotCacheData.Max7)!=Integer.MIN_VALUE)
246246
{
247-
GraphHelper.addValuesToHotcacheGraph(m_hotcacheGraph7, (double) entry.getValue().getColumn(HotCacheData.Mean7), Integer.valueOf((int) entry.getValue().getColumn(HotCacheData.Max7)).longValue(), Integer.valueOf((int) entry.getValue().getColumn(HotCacheData.Min7)).longValue());
247+
GraphHelper.addValuesToHotcacheGraph(m_hotcacheGraph7, (double) entry.getValue().getColumn(HotCacheData.Mean7), (long) entry.getValue().getColumn(HotCacheData.Max7), (long) entry.getValue().getColumn(HotCacheData.Min7));
248248
}
249249
break;
250250
}

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/panel/util/AbstractMenuOption.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ protected VisualVMModel getMode()
296296
protected int getSelectedRow()
297297
{
298298
int nSelectedRow = f_jtable != null ? f_jtable.getSelectedRow() : -1;
299-
if (nSelectedRow != -1)
299+
if (nSelectedRow != -1 && f_jtable != null)
300300
{
301301
// set the correct model row index taking into account sorting
302302
nSelectedRow = f_jtable.convertRowIndexToModel(nSelectedRow);

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/tablemodel/model/PersistenceData.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,7 @@ private Data createData(String sServiceName, String sPersistenceMode, String sDo
375375
Set<ObjectName> setResult = requestSender
376376
.getCompleteObjectName(new ObjectName(getMBeanName(sServiceName)));
377377

378-
String sFQN = null;
379-
380-
for (Object oResult : setResult)
381-
{
382-
sFQN = oResult.toString();
383-
break;
384-
}
378+
String sFQN = setResult.isEmpty() ? null : setResult.iterator().next().toString();
385379

386380
sStatus = requestSender.getAttribute(new ObjectName(sFQN), "OperationStatus");
387381
}

0 commit comments

Comments
 (0)