Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2025 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.coherence.plugin.visualvm;

import org.graalvm.visualvm.application.Application;

import static org.graalvm.visualvm.host.Host.UNKNOWN_HOST;

/**
* MockApplication is a class used to register a REST connection to fix
* issue when unregistering application..
*/
public class MockApplication extends Application
{
// ---- constructors ----------------------------------------------------

/**
* Constructs a new MockApplication instance.
*
* @param id the unique identifier for this application
*/
public MockApplication(String id)
{
super(UNKNOWN_HOST, id);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2025 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
Expand Down Expand Up @@ -58,11 +58,9 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -167,6 +165,12 @@ protected DataViewComponent createComponent()
addModelForApplication(m_application, model);
}

if (m_application == null)
{
// this is called from REST, so create a dummy application, so the visual VM Model gets cleaned up
m_application = new MockApplication(String.valueOf(f_counter.incrementAndGet()));
}

boolean fClusterSnapshotEnabled = com.oracle.coherence.plugin.visualvm.GlobalPreferences
.sharedInstance().isClusterSnapshotEnabled();

Expand Down Expand Up @@ -516,4 +520,6 @@ public static void addModelForApplication(Application application, VisualVMModel
* Set of panels to refresh and update.
*/
private final Set<AbstractCoherencePanel> f_setPanels = new LinkedHashSet<>();

private static final AtomicInteger f_counter = new AtomicInteger(0);
}