use of javax.management.OperationsException in project jdk8u_jdk by JetBrains.
the class MBeanInstantiator method deserialize.
/**
* De-serializes a byte array in the context of a classloader.
*
* @param loader the classloader to use for de-serialization
* @param data The byte array to be de-sererialized.
*
* @return The de-serialized object stream.
*
* @exception OperationsException Any of the usual Input/Output related
* exceptions.
*/
public ObjectInputStream deserialize(ClassLoader loader, byte[] data) throws OperationsException {
// Check parameter validity
if (data == null) {
throw new RuntimeOperationsException(new IllegalArgumentException(), "Null data passed in parameter");
}
if (data.length == 0) {
throw new RuntimeOperationsException(new IllegalArgumentException(), "Empty data passed in parameter");
}
// Object deserialization
ByteArrayInputStream bIn;
ObjectInputStream objIn;
bIn = new ByteArrayInputStream(data);
try {
objIn = new ObjectInputStreamWithLoader(bIn, loader);
} catch (IOException e) {
throw new OperationsException("An IOException occurred trying to de-serialize the data");
}
return objIn;
}
use of javax.management.OperationsException in project geode by apache.
the class ConnectionNotificationFilterImpl method initializeHelperMbean.
private void initializeHelperMbean() {
try {
memberInfoWithStatsMBean = new MemberInfoWithStatsMBean(this);
MBeanServer mbs = getMBeanServer();
mbs.registerMBean(memberInfoWithStatsMBean, memberInfoWithStatsMBean.getObjectName());
/*
* We are not re-throwing these exceptions as failure create/register the GemFireTypesWrapper
* will not stop the Agent from working. But we are logging it as it could be an indication of
* some problem. Also not creating Localized String for the exception.
*/
} catch (OperationsException e) {
logger.info(LocalizedMessage.create(LocalizedStrings.AgentImpl_FAILED_TO_INITIALIZE_MEMBERINFOWITHSTATSMBEAN), e);
} catch (MBeanRegistrationException e) {
logger.info(LocalizedMessage.create(LocalizedStrings.AgentImpl_FAILED_TO_INITIALIZE_MEMBERINFOWITHSTATSMBEAN), e);
} catch (AdminException e) {
logger.info(LocalizedMessage.create(LocalizedStrings.AgentImpl_FAILED_TO_INITIALIZE_MEMBERINFOWITHSTATSMBEAN), e);
}
}
use of javax.management.OperationsException in project apache-kafka-on-k8s by banzaicloud.
the class SanitizerTest method verifyJmx.
private void verifyJmx(String sanitizedValue, int c) throws MalformedObjectNameException {
Object mbean = new TestStat();
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName objectName = new ObjectName("test:key=" + sanitizedValue);
try {
server.registerMBean(mbean, objectName);
server.unregisterMBean(objectName);
} catch (OperationsException | MBeanException e) {
fail("Could not register char=\\u" + c);
}
}
use of javax.management.OperationsException in project kafka by apache.
the class SanitizerTest method verifyJmx.
private void verifyJmx(String sanitizedValue, int c) throws MalformedObjectNameException {
Object mbean = new TestStat();
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName objectName = new ObjectName("test:key=" + sanitizedValue);
try {
server.registerMBean(mbean, objectName);
server.unregisterMBean(objectName);
} catch (OperationsException | MBeanException e) {
fail("Could not register char=\\u" + c);
}
}
use of javax.management.OperationsException in project jdk8u_jdk by JetBrains.
the class MBeanInstantiator method deserialize.
/**
* De-serializes a byte array in the context of a given MBean class loader.
* <P>The class loader is the one that loaded the class with name
* "className".
* <P>The name of the class loader to be used for loading the specified
* class is specified. If null, a default one has to be provided (for a
* MBean Server, its own class loader will be used).
*
* @param className The name of the class whose class loader should
* be used for the de-serialization.
* @param data The byte array to be de-sererialized.
* @param loaderName The name of the class loader to be used for loading
* the specified class. If null, a default one has to be provided (for a
* MBean Server, its own class loader will be used).
*
* @return The de-serialized object stream.
*
* @exception InstanceNotFoundException The specified class loader MBean is
* not found.
* @exception OperationsException Any of the usual Input/Output related
* exceptions.
* @exception ReflectionException The specified class could not be loaded
* by the specified class loader.
*/
public ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data, ClassLoader loader) throws InstanceNotFoundException, OperationsException, ReflectionException {
// Check parameter validity
if (data == null) {
throw new RuntimeOperationsException(new IllegalArgumentException(), "Null data passed in parameter");
}
if (data.length == 0) {
throw new RuntimeOperationsException(new IllegalArgumentException(), "Empty data passed in parameter");
}
if (className == null) {
throw new RuntimeOperationsException(new IllegalArgumentException(), "Null className passed in parameter");
}
ReflectUtil.checkPackageAccess(className);
Class<?> theClass;
if (loaderName == null) {
// Load the class using the agent class loader
theClass = findClass(className, loader);
} else {
// Get the class loader MBean
try {
ClassLoader instance = null;
instance = getClassLoader(loaderName);
if (instance == null)
throw new ClassNotFoundException(className);
theClass = Class.forName(className, false, instance);
} catch (ClassNotFoundException e) {
throw new ReflectionException(e, "The MBean class could not be loaded by the " + loaderName.toString() + " class loader");
}
}
// Object deserialization
ByteArrayInputStream bIn;
ObjectInputStream objIn;
bIn = new ByteArrayInputStream(data);
try {
objIn = new ObjectInputStreamWithLoader(bIn, theClass.getClassLoader());
} catch (IOException e) {
throw new OperationsException("An IOException occurred trying to de-serialize the data");
}
return objIn;
}
Aggregations