Hi all,
I'm using ActiveMQ 5.3.0 under OSGi environment from two years without any
notable issue.
Now, I need to add authorization management for users publishing/subscribing
to particular topics.
For this purpose, I developed a plugin which implements
org.apache.activemq.security.MessageAuthorizationPolicy: in the method
public boolean isAllowedToConsume(ConnectionContext context, Message
message)
where I read the incoming message, I check that the current user is allowed
to consume such a message and I return true/false accordingly to this check.
In particular, I use text messages (short XML fragments...), so, I use this
snippet to read the current TextMessage:
if (message instanceof TextMessage) {
String xmlText = "";
try {
xmlText = xml.getText();
System.out.println(xmlText);
... //parse the message and check for permission...
} catch (JMSException e) {
... //manage exception
}
}
It seems to me (but maybe I'm wrong!!) that this code creates a race with
the code contained in org.apache.activemq.openwire.v5.MessageMarshaller:
public void tightMarshal2(OpenWireFormat wireFormat, Object o,
DataOutput dataOut, BooleanStream bs) throws IOException {
...
tightMarshalByteSequence2(info.getContent(), dataOut, bs); //here,
info.getContent() is null!!
...
}
and in fact I receive a NullPointerException whose stacktrace is:
Exception in thread "BrokerService"
java.lang.NullPointerException
at
org.apache.activemq.openwire.v5.BaseDataStreamMarshaller.tightMarshalByteSequence2(BaseDataStreamMarshaller.java:431)
at
org.apache.activemq.openwire.v5.MessageMarshaller.tightMarshal2(MessageMarshaller.java:180)
at
org.apache.activemq.openwire.v5.ActiveMQMessageMarshaller.tightMarshal2(ActiveMQMessageMarshaller.java:89)
at
org.apache.activemq.openwire.v5.ActiveMQTextMessageMarshaller.tightMarshal2(ActiveMQTextMessageMarshaller.java:89)
at
org.apache.activemq.openwire.OpenWireFormat.tightMarshalNestedObject2(OpenWireFormat.java:430)
at
org.apache.activemq.openwire.v5.BaseDataStreamMarshaller.tightMarshalNestedObject2(BaseDataStreamMarshaller.java:136)
at
org.apache.activemq.openwire.v5.MessageDispatchMarshaller.tightMarshal2(MessageDispatchMarshaller.java:105)
at
org.apache.activemq.openwire.OpenWireFormat.marshal(OpenWireFormat.java:240)
at
org.apache.activemq.transport.tcp.TcpTransport.oneway(TcpTransport.java:166)
at
org.apache.activemq.transport.InactivityMonitor.oneway(InactivityMonitor.java:237)
at
org.apache.activemq.transport.TransportFilter.oneway(TransportFilter.java:83)
at
org.apache.activemq.transport.WireFormatNegotiator.oneway(WireFormatNegotiator.java:104)
at
org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:40)
at
org.apache.activemq.broker.TransportConnection.dispatch(TransportConnection.java:1190)
at
org.apache.activemq.broker.TransportConnection.processDispatch(TransportConnection.java:779)
at
org.apache.activemq.broker.TransportConnection.iterate(TransportConnection.java:815)
at
org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122)
at
org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Now, if I remove the snippet to read the XML content of the message in
isAllowedToConsume(...), all seeems returning fine, but I need such a
control!!!
So, is there a way to correctly read a TextMessage without affecting other
consumers?
Thank you very much and sorry for the long question!!
Bye
cghersi
--
View this message in context:
http://activemq.2283324.n4.nabble.com/ActiveMQ-NullPointerException-on-broker-while-checking-for-authorization-tp4434405p4434405.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.