@Test public void unregisterMBeanInstanceNotFoundMessageLogged() throws Exception { // This mocks the race condition where the server indicates that the object is registered, // but when we go to unregister it, it has already been unregistered. when(mockMBeanServer.isRegistered(objectName)).thenReturn(true); // Mock unregisterMBean to throw the InstanceNotFoundException, indicating that the MBean // has already been unregistered doThrow(new InstanceNotFoundException()).when(mockMBeanServer).unregisterMBean(objectName); MBeanJMXAdapter mBeanJMXAdapter = spy(new MBeanJMXAdapter(distMember)); MBeanJMXAdapter.mbeanServer = mockMBeanServer; mBeanJMXAdapter.unregisterMBean(objectName); // InstanceNotFoundException should just log a debug message as it is essentially a no-op // during unregistration verify(mBeanJMXAdapter, times(1)).logRegistrationWarning(any(ObjectName.class), eq(false)); }
return persister; } else { throw new InstanceNotFoundException(objectName.toString());
private Set<ObjectName> searchMBeans(MBeanServerExecutor pServerManager, ObjectName pObjectName) throws IOException, InstanceNotFoundException { Set<ObjectName> names = pServerManager.queryNames(pObjectName); if (names.size() == 0) { throw new InstanceNotFoundException("No MBean with pattern " + pObjectName + " found for reading attributes"); } return names; }
/** * Add an exception which occurred during extraction of an {@link MBeanInfo} for * a certain {@link ObjectName} to this map. * * @param pName MBean name for which the error occurred * @param pExp exception occurred * @throws IllegalStateException if this method decides to rethrow the exception */ public void handleException(ObjectName pName, InstanceNotFoundException pExp) throws InstanceNotFoundException { // This happen happens for JBoss 7.1 in some cases (i.e. ResourceAdapterModule) if (pathStack.size() == 0) { addException(pName, pExp); } else { throw new InstanceNotFoundException("InstanceNotFoundException for MBean " + pName + " (" + pExp.getMessage() + ")"); } }
@Override public void unregisterMBean(ObjectName name) throws InstanceNotFoundException { if (mbeans.remove(name) == null) { throw new InstanceNotFoundException(format("MBean not found: %s", name)); } }
private DynamicMBean getMBean(ObjectName name) throws InstanceNotFoundException { DynamicMBean mbean = mbeans.get(name); if (mbean == null) { throw new InstanceNotFoundException(format("MBean not found: %s", name)); } return mbean; }
private DynamicMBean getMBean(ObjectName name) throws InstanceNotFoundException { DynamicMBean mbean = mbeans.get(name); if (mbean == null) { throw new InstanceNotFoundException(format("MBean not found: %s", name)); } return mbean; }
public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException { ObjectName mapped = mappings.remove(name); if (mapped == null) { throw new InstanceNotFoundException(name.toString()); } delegate.unregisterMBean(mapped); }
private Set<ObjectName> searchMBeans(MBeanServerExecutor pServerManager, ObjectName pObjectName) throws IOException, InstanceNotFoundException { Set<ObjectName> names = pServerManager.queryNames(pObjectName); if (names.size() == 0) { throw new InstanceNotFoundException("No MBean with pattern " + pObjectName + " found for reading attributes"); } return names; }
void unregister(Object object) throws InstanceNotFoundException { if (reportedBeans.remove(new Reference(object)) == null) { throw new InstanceNotFoundException(object + " not found"); } }
private Set<ObjectName> searchMBeans(MBeanServerExecutor pServerManager, ObjectName pObjectName) throws IOException, InstanceNotFoundException { Set<ObjectName> names = pServerManager.queryNames(pObjectName); if (names.size() == 0) { throw new InstanceNotFoundException("No MBean with pattern " + pObjectName + " found for reading attributes"); } return names; }
public final Object instantiate( final String str, final ObjectName objectName, final Object[] obj, final String[] str3) throws ReflectionException, MBeanException, InstanceNotFoundException { if(objectName == null) throw new InstanceNotFoundException(); return getDelegateMBeanServer().instantiate(str, objectName, obj, str3); }
public final ClassLoader getClassLoader( final ObjectName objectName) throws InstanceNotFoundException { if(objectName == null) throw new InstanceNotFoundException(); return getDelegateMBeanServer().getClassLoader( objectName ); }
public final Object instantiate( final String str, final ObjectName objectName) throws ReflectionException, MBeanException, InstanceNotFoundException { if(objectName == null) throw new InstanceNotFoundException(); return getDelegateMBeanServer().instantiate(str, objectName); }
@Override public final InstanceNotFoundException mbeanNotFound(final ObjectName name) { final InstanceNotFoundException result = new InstanceNotFoundException(String.format(getLoggingLocale(), mbeanNotFound$str(), name)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String mbeanRegistrationFailed = "WFLYJMX0018: Failed to register mbean [%s]";
@Override public final InstanceNotFoundException noMBeanCalled(final ObjectName name) { final InstanceNotFoundException result = new InstanceNotFoundException(String.format(getLoggingLocale(), noMBeanCalled$str(), name)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String couldNotFindJ2eeType = "WFLYEEMGMT0007: Could not find %s";
private <E extends Throwable> void processResourceConnector(final String resourceName, final Acceptor<ManagedResourceConnector, E> acceptor) throws E, InstanceNotFoundException { final BundleContext context = getBundleContext(); try (final ManagedResourceConnectorClient client = ManagedResourceConnectorClient.tryCreate(context, resourceName) .orElseThrow(() -> new InstanceNotFoundException(String.format("Resource %s doesn't exist", resourceName)))) { acceptor.accept(client.get()); } }
@Override public final InstanceNotFoundException couldNotFindJ2eeType(final String j2eeType) { final InstanceNotFoundException result = new InstanceNotFoundException(String.format(getLoggingLocale(), couldNotFindJ2eeType$str(), j2eeType)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String invalidObjectName = "WFLYEEMGMT0008: Invalid ObjectName: %s";
public String getJMXPort(String instance) throws InstanceNotFoundException { Server s = domain.getServerNamed(instance); if (s == null) throw new InstanceNotFoundException(); return new PropertyResolver(domain, instance).getPropertyValue("JMX_SYSTEM_CONNECTOR_PORT"); }
public ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException { if (!contains(name)) throw new InstanceNotFoundException(name + " not registered."); return new ServerObjectInstance(qualifyName(name), get(name).getResourceClassName(), delegate.getMBeanServerId()); }