From 496cd117111a799b5dff1b6283f9b469d0713781 Mon Sep 17 00:00:00 2001 From: Tim Middleton Date: Tue, 4 Oct 2022 10:48:42 +0800 Subject: [PATCH] Fix NPE in report environment for older Coherence versions (#29) * Fix NPE in report environment for older Coh versions * Fixup sonarcloud complaint * update workflow --- .github/workflows/test-against-released.yml | 8 +++----- .../plugin/visualvm/panel/CoherenceMemberPanel.java | 10 +++++++++- .../oracle/coherence/plugin/visualvm/Bundle.properties | 2 ++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-against-released.yml b/.github/workflows/test-against-released.yml index cc1f6d3..9875cb8 100644 --- a/.github/workflows/test-against-released.yml +++ b/.github/workflows/test-against-released.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -44,10 +44,8 @@ jobs: version: - 14.1.1-0-10 - 14.1.1-0-9 - - 21.06.1 - - 21.12.4 - - 22.06.1 - 22.06.2 + - 22.09 steps: - name: Checkout @@ -63,7 +61,7 @@ jobs: - name: Set up JDK 11 for Build uses: actions/setup-java@v1 with: - java-version: '11' + java-version: '17' - name: Print Versions run: mvn -version && ant -version diff --git a/coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/panel/CoherenceMemberPanel.java b/coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/panel/CoherenceMemberPanel.java index 3737fa3..47ba919 100755 --- a/coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/panel/CoherenceMemberPanel.java +++ b/coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/panel/CoherenceMemberPanel.java @@ -26,6 +26,7 @@ package com.oracle.coherence.plugin.visualvm.panel; +import com.oracle.coherence.plugin.visualvm.Localization; import com.oracle.coherence.plugin.visualvm.helper.GraphHelper; import com.oracle.coherence.plugin.visualvm.helper.RenderHelper; import com.oracle.coherence.plugin.visualvm.helper.RequestSender; @@ -636,12 +637,19 @@ public String getMenuItem() /** * Return a sanitized message to make common errors more meaningful. * @param e {@link Exception} to get message from + * * @return final message */ private String getSanitizedMessage(Exception e) { String sError = e.getMessage(); - return sError.contains("name cannot be null") ? "Node no longer available." : sError; + + if (sError == null) + { + return Localization.getLocalText("LBL_operation_not_available"); + } + + return sError.contains("name cannot be null") ? Localization.getLocalText("LBL_node_not_available") : sError; } // ----- constants ------------------------------------------------------ diff --git a/coherence-visualvm-plugin/src/main/resources/com/oracle/coherence/plugin/visualvm/Bundle.properties b/coherence-visualvm-plugin/src/main/resources/com/oracle/coherence/plugin/visualvm/Bundle.properties index 8dbe217..23073b9 100644 --- a/coherence-visualvm-plugin/src/main/resources/com/oracle/coherence/plugin/visualvm/Bundle.properties +++ b/coherence-visualvm-plugin/src/main/resources/com/oracle/coherence/plugin/visualvm/Bundle.properties @@ -126,6 +126,8 @@ LBL_thread_dump_completed=Completed. LBL_copy_to_clipboard=Copy contents to Clipboard LBL_copied=Data has been copied to the Clipboard. LBL_data_saved=Thread Dump has been saved to {0}. +LBL_operation_not_available=Operation is not available in this version. +LBL_node_not_available=Node no longer available. # CoherencePersistencePanel LBL_total_active_space=Total Active Persistence Space Used (MB)