4 Replies Latest reply on Oct 11, 2007 6:26 AM by Ales Justin

    Weird SimpleValueSupport instance

    Ales Justin Master

      I stumbled upon this weird SimpleValueSupport instance:

      value: java.lang.Object = {org.jboss.metatype.api.values.SimpleValueSupport@8630}"SimpleMetaType:java.lang.Integer:5"
       metaType: org.jboss.metatype.api.types.SimpleMetaType = {org.jboss.metatype.api.types.SimpleMetaType@8638}"SimpleMetaType:java.lang.Integer"
       cachedHashCode: int = -2056817302
       cachedToString: java.lang.String = {java.lang.String@8873}"SimpleMetaType:java.lang.Integer"
       className: java.lang.String = {java.lang.String@8874}"java.lang.Integer"
       description: java.lang.String = {java.lang.String@8874}"java.lang.Integer"
       typeName: java.lang.String = {java.lang.String@8874}"java.lang.Integer"
       array: boolean = false
       value: java.io.Serializable = {java.lang.String@8872}"5"
      


      MetaType == Integer, value == String.
      Which again introduces CCE. ;-(

        • 1. Re: Weird SimpleValueSupport instance
          Scott Stark Master

          You have to input a valid MetaValue. You should validate the value using the MetaValue.getType().isValue(Object obj) call, or SimpleValueSupport.setValue should be doing this.

          • 2. Re: Weird SimpleValueSupport instance
            Ales Justin Master

            Cause:

            2007-10-10 16:42:50,750 DEBUG [org.jboss.system.deployers.managed.ServiceMetaDataICF] Failed to get property value for bean: org.jboss.resource.connectionmanager.JBossManagedConnectionPool, property: minSize
            java.lang.IllegalArgumentException: Value and metatype are differ in type: SimpleMetaType:java.lang.Integer:5
             at org.jboss.metatype.api.values.SimpleValueSupport.setValue(SimpleValueSupport.java:102)
             at org.jboss.metatype.api.values.SimpleValueSupport.<init>(SimpleValueSupport.java:75)
             at org.jboss.metatype.plugins.values.DefaultMetaValueFactory.createSimpleValue(DefaultMetaValueFactory.java:129)
             at org.jboss.metatype.plugins.values.DefaultMetaValueFactory.internalCreate(DefaultMetaValueFactory.java:492)
             at org.jboss.metatype.plugins.values.DefaultMetaValueFactory.create(DefaultMetaValueFactory.java:442)
             at org.jboss.system.deployers.managed.ServiceMetaDataICF.getValue(ServiceMetaDataICF.java:121)
             at org.jboss.managed.plugins.factory.AbstractManagedObjectFactory.populateValues(AbstractManagedObjectFactory.java:605)
             at org.jboss.managed.plugins.factory.AbstractManagedObjectFactory.populateManagedObject(AbstractManagedObjectFactory.java:525)
             at org.jboss.managed.plugins.factory.AbstractManagedObjectFactory.initManagedObject(AbstractManagedObjectFactory.java:171)
             at org.jboss.managed.plugins.factory.AbstractManagedObjectFactory.getValue(AbstractManagedObjectFactory.java:695)
             at org.jboss.managed.plugins.factory.AbstractManagedObjectFactory.populateValues(AbstractManagedObjectFactory.java:605)
             at org.jboss.managed.plugins.factory.AbstractManagedObjectFactory.populateManagedObject(AbstractManagedObjectFactory.java:525)
             at org.jboss.managed.plugins.factory.AbstractManagedObjectFactory.initManagedObject(AbstractManagedObjectFactory.java:171)
             at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.build(AbstractParsingDeployerWithOutput.java:290)
             at org.jboss.deployers.plugins.deployers.DeployerWrapper.build(DeployerWrapper.java:202)
             at org.jboss.deployers.plugins.deployers.DeployersImpl.getManagedObjects(DeployersImpl.java:339)
             at org.jboss.deployers.plugins.main.MainDeployerImpl.getManagedObjects(MainDeployerImpl.java:458)
             at org.jboss.deployers.plugins.main.MainDeployerImpl.getManagedDeployment(MainDeployerImpl.java:432)
             at org.jboss.profileservice.management.ManagementViewImpl.loadProfile(ManagementViewImpl.java:164)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:121)
             at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
             at org.jboss.profileservice.remoting.ProfileServiceInvocationHandler.invoke(ProfileServiceInvocationHandler.java:56)
             at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:769)
             at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
             at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
             at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
            2007-10-10 16:42:50,750 DEBUG [org.jboss.system.deployers.managed.ServiceMetaDataICF] Failed to get property value for bean: org.jboss.resource.connectionmanager.JBossManagedConnectionPool, property: maxSize
            java.lang.IllegalArgumentException: Value and metatype are differ in type: SimpleMetaType:java.lang.Integer:20
             at org.jboss.metatype.api.values.SimpleValueSupport.setValue(SimpleValueSupport.java:102)
             at org.jboss.metatype.api.values.SimpleValueSupport.<init>(SimpleValueSupport.java:75)
             at org.jboss.metatype.plugins.values.DefaultMetaValueFactory.createSimpleValue(DefaultMetaValueFactory.java:129)
             at org.jboss.metatype.plugins.values.DefaultMetaValueFactory.internalCreate(DefaultMetaValueFactory.java:492)
             at org.jboss.metatype.plugins.values.DefaultMetaValueFactory.create(DefaultMetaValueFactory.java:442)
             at org.jboss.system.deployers.managed.ServiceMetaDataICF.getValue(ServiceMetaDataICF.java:121)
             at org.jboss.managed.plugins.factory.AbstractManagedObjectFactory.populateValues(AbstractManagedObjectFactory.java:605)
             at org.jboss.managed.plugins.factory.AbstractManagedObjectFactory.populateManagedObject(AbstractManagedObjectFactory.java:525)
             at org.jboss.managed.plugins.factory.AbstractManagedObjectFactory.initManagedObject(AbstractManagedObjectFactory.java:171)
             at org.jboss.managed.plugins.factory.AbstractManagedObjectFactory.getValue(AbstractManagedObjectFactory.java:695)
             at org.jboss.managed.plugins.factory.AbstractManagedObjectFactory.populateValues(AbstractManagedObjectFactory.java:605)
             at org.jboss.managed.plugins.factory.AbstractManagedObjectFactory.populateManagedObject(AbstractManagedObjectFactory.java:525)
             at org.jboss.managed.plugins.factory.AbstractManagedObjectFactory.initManagedObject(AbstractManagedObjectFactory.java:171)
             at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.build(AbstractParsingDeployerWithOutput.java:290)
             at org.jboss.deployers.plugins.deployers.DeployerWrapper.build(DeployerWrapper.java:202)
             at org.jboss.deployers.plugins.deployers.DeployersImpl.getManagedObjects(DeployersImpl.java:339)
             at org.jboss.deployers.plugins.main.MainDeployerImpl.getManagedObjects(MainDeployerImpl.java:458)
             at org.jboss.deployers.plugins.main.MainDeployerImpl.getManagedDeployment(MainDeployerImpl.java:432)
             at org.jboss.profileservice.management.ManagementViewImpl.loadProfile(ManagementViewImpl.java:164)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:121)
             at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
             at org.jboss.profileservice.remoting.ProfileServiceInvocationHandler.invoke(ProfileServiceInvocationHandler.java:56)
             at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:769)
             at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
             at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
             at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
            


            Which makes sense with the following code

             @Override
             public List<ServiceAttributeMetaData> buildAttributes(ManagedConnectionFactoryDeploymentMetaData md)
             {
             List<ServiceAttributeMetaData> poolAttributes = new ArrayList<ServiceAttributeMetaData>();
             ServiceAttributeMetaData poolAttribute = null;
            
             poolAttribute = buildSimpleAttribute("PoolJndiName", md.getJndiName());
             poolAttributes.add(poolAttribute);
            
             poolAttribute = buildSimpleAttribute("MinSize", String.valueOf(md.getMinSize()));
             poolAttributes.add(poolAttribute);
            
             poolAttribute = buildSimpleAttribute("MaxSize", String.valueOf(md.getMaxSize()));
             poolAttributes.add(poolAttribute);
            


            and

             if (metaType.isSimple())
             result = createSimpleValue((SimpleMetaType<Serializable>) metaType, (Serializable) value);
            


            At which point to fix this?
            Or is this expected behaviour?

            • 3. Re: Weird SimpleValueSupport instance
              Scott Stark Master

              The ServiceMetaDataICF class has to deal with any type conversion issues due to the attribute metadata not matching the underlying mbean attribute type.

              • 4. Re: Weird SimpleValueSupport instance
                Ales Justin Master

                We could add

                value = typeInfo.convert(value)
                

                right after we fully determine typeInfo to either DefaultMetaValueFactory or just to ServiceMetaDataICF.

                Just tested addition to DefaultMetaValueFactory and the tests pass.

                OK to commit it there?