Skip to content

Commit 75be8ac

Browse files
authored
Sonarcloud updates (#74)
* Sonarcloud updates * further sonarcloud updates * further sonarcloud updates
1 parent 79964c4 commit 75be8ac

11 files changed

+115
-112
lines changed

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/VisualVMModel.java

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -468,60 +468,57 @@ public List<Entry<Object, Data>> getData(RequestSender requestSender, Class<?> c
468468

469469
// if we have not yet evaluated if the reporter is available, e.g. value of null,
470470
// then do it. Also check for the version as well.
471-
if (isReporterAvailable() == null || is1213AndAbove() == null)
471+
if ((isReporterAvailable() == null || is1213AndAbove() == null) && clusterData != null)
472472
{
473473
// get the Coherence version. Easier to do if we are connected to a cluster,
474474
// but we have JMX connection as we have to look in data we collected.
475475

476-
if (clusterData != null)
476+
for (Entry<Object, Data> entry : clusterData)
477477
{
478-
for (Entry<Object, Data> entry : clusterData)
478+
// there will only be one cluster entry
479+
480+
String sCoherenceVersion =
481+
entry.getValue().getColumn(ClusterData.VERSION).toString().replaceFirst(" .*$", "")
482+
.replaceFirst("[\\.-]SNAPSHOT.*$","").replaceAll("-",".");
483+
m_sClusterVersion = sCoherenceVersion;
484+
485+
int nVersion = 0;
486+
487+
if (sCoherenceVersion.startsWith("3.5"))
488+
{
489+
// manual check as version numbering changed after 35
490+
nVersion = 353;
491+
}
492+
else if (sCoherenceVersion.startsWith("2"))
493+
{
494+
// check for versions such as 20.06 or 20.06.01 and convert them to an ever-increasing number
495+
// 20.06 -> 2006000
496+
// 20.06.1 -> 2006100
497+
// 20.06.10 -> 2006100
498+
String sStrippedVersion = sCoherenceVersion.replaceAll("\\.", "");
499+
nVersion = Integer.parseInt(sStrippedVersion) * (int) Math.pow(10, 7 - (double) sStrippedVersion.length());
500+
}
501+
else
502+
{
503+
nVersion = Integer.parseInt(sCoherenceVersion.replaceAll("\\.", ""));
504+
}
505+
506+
LOGGER.log(Level.INFO, "Raw Coherence version identified as {0}", m_sClusterVersion);
507+
LOGGER.log(Level.INFO, "Numeric Coherence version identified as {0}", String.format("%d", nVersion));
508+
509+
if (nVersion >= 121300)
510+
{
511+
// only set if the reporter available is it is not already set as we may have
512+
// got to this code path because is1213AndAbove() is still null
513+
setReporterAvailable(isReporterAvailable() == null || isReporterAvailable());
514+
m_fis1213AndAbove = true;
515+
}
516+
else
479517
{
480-
// there will only be one cluster entry
481-
482-
String sCoherenceVersion =
483-
entry.getValue().getColumn(ClusterData.VERSION).toString().replaceFirst(" .*$", "")
484-
.replaceFirst("[\\.-]SNAPSHOT.*$","").replaceAll("-",".");
485-
m_sClusterVersion = sCoherenceVersion;
486-
487-
int nVersion = 0;
488-
489-
if (sCoherenceVersion.startsWith("3.5"))
490-
{
491-
// manual check as version numbering changed after 35
492-
nVersion = 353;
493-
}
494-
else if (sCoherenceVersion.startsWith("2"))
495-
{
496-
// check for versions such as 20.06 or 20.06.01 and convert them to an ever-increasing number
497-
// 20.06 -> 2006000
498-
// 20.06.1 -> 2006100
499-
// 20.06.10 -> 2006100
500-
String sStrippedVersion = sCoherenceVersion.replaceAll("\\.", "");
501-
nVersion = Integer.parseInt(sStrippedVersion) * (int) Math.pow(10, 7 - (double) sStrippedVersion.length());
502-
}
503-
else
504-
{
505-
nVersion = Integer.parseInt(sCoherenceVersion.replaceAll("\\.", ""));
506-
}
507-
508-
LOGGER.log(Level.INFO, "Raw Coherence version identified as {0}", m_sClusterVersion);
509-
LOGGER.log(Level.INFO, "Numeric Coherence version identified as {0}", String.format("%d", nVersion));
510-
511-
if (nVersion >= 121300)
512-
{
513-
// only set if the reporter available is it is not already set as we may have
514-
// got to this code path because is1213AndAbove() is still null
515-
setReporterAvailable(isReporterAvailable() == null || isReporterAvailable());
516-
m_fis1213AndAbove = true;
517-
}
518-
else
519-
{
520-
setReporterAvailable(isReporterAvailable() != null && isReporterAvailable());
521-
m_fis1213AndAbove = false;
522-
}
523-
m_nClusterVersion = nVersion;
518+
setReporterAvailable(isReporterAvailable() != null && isReporterAvailable());
519+
m_fis1213AndAbove = false;
524520
}
521+
m_nClusterVersion = nVersion;
525522
}
526523
}
527524

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/datasource/CoherenceClusterDataSourceDescriptorProvider.java

Lines changed: 2 additions & 2 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
@@ -75,5 +75,5 @@ public static void unregister()
7575
/**
7676
* The static singleton instance of {@link CoherenceClusterDataSourceDescriptorProvider}.
7777
*/
78-
final private static CoherenceClusterDataSourceDescriptorProvider INSTANCE = new CoherenceClusterDataSourceDescriptorProvider();
78+
private final static CoherenceClusterDataSourceDescriptorProvider INSTANCE = new CoherenceClusterDataSourceDescriptorProvider();
7979
}

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/datasource/CoherenceClusterDataSourceViewProvider.java

Lines changed: 2 additions & 2 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
@@ -80,5 +80,5 @@ public static void unregister()
8080
/**
8181
* The singleton instance of {@link CoherenceClusterDataSourceViewProvider}.
8282
*/
83-
final protected static CoherenceClusterDataSourceViewProvider INSTANCE = new CoherenceClusterDataSourceViewProvider();
83+
protected final static CoherenceClusterDataSourceViewProvider INSTANCE = new CoherenceClusterDataSourceViewProvider();
8484
}

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/discovery/DiscoverCoherenceClusterAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ protected boolean isEnabled(Host host) {
163163
@Override
164164
protected void updateState(Set<Host> selectedHosts)
165165
{
166-
if (tracksSelection)
166+
if (m_fTracksSelection)
167167
{
168168
super.updateState(selectedHosts);
169169
}
@@ -187,7 +187,7 @@ public static synchronized DiscoverCoherenceClusterAction selectionAware()
187187
if (selectionAware == null)
188188
{
189189
selectionAware = new DiscoverCoherenceClusterAction();
190-
selectionAware.tracksSelection = true;
190+
selectionAware.m_fTracksSelection = true;
191191
}
192192
return selectionAware;
193193
}
@@ -208,5 +208,5 @@ public static synchronized DiscoverCoherenceClusterAction selectionAware()
208208

209209
private static DiscoverCoherenceClusterAction alwaysEnabled;
210210
private static DiscoverCoherenceClusterAction selectionAware;
211-
private boolean tracksSelection = false;
211+
private boolean m_fTracksSelection = false;
212212
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public static void addValuesToCompletedTasksGraph(SimpleXYChartSupport graph, lo
307307
*/
308308
public static void addValuesToTotalProxyConnectionsGraph(SimpleXYChartSupport graph, int cTotalConnections)
309309
{
310-
graph.addValues(System.currentTimeMillis(), new long[] {(long) cTotalConnections});
310+
graph.addValues(System.currentTimeMillis(), new long[] {cTotalConnections});
311311
}
312312

313313
/**

0 commit comments

Comments
 (0)