[JBoss JIRA] Created: (JBRULES-586) DefaultExpander incorrectly strips leading and trailing spaces
by Adam Lewandowski (JIRA)
DefaultExpander incorrectly strips leading and trailing spaces
--------------------------------------------------------------
Key: JBRULES-586
URL: http://jira.jboss.com/jira/browse/JBRULES-586
Project: JBoss Rules
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: Drl Parser/Builder
Affects Versions: 3.0.5
Reporter: Adam Lewandowski
Assigned To: Mark Proctor
When using a DSL expander, token values with leading or trailing spaces get the spaces stripped when inserted into the target template. This causes the resulting rule definition to be incorrect.
Example:
DSL: [when]String is "{value}"=SomeFact(value=="{value}")
Input string (note the trailing space): String is "blah "
Expanded string (note the lack of a trailing space): SomeFact(value=="blah")
The same thing occurs for leading spaces as well. Internal spaces are fine.
Also interesting is that if there are more than one leading/trailing space, NLExpressionCompiler throws an IllegalArgumentException: Expression was not expandable: String is " blah"
The problem seems to be in the org.drools.lang.dsl.template.Chunk class. It is stripping the leading/trailing spaces from values in the map populated by buildValueMap().
Unit Test:
import java.io.StringReader;
import org.drools.lang.dsl.DefaultExpander;
import junit.framework.TestCase;
public class DroolsDslTemplateTest extends TestCase {
private DefaultExpander expander;
public void setUp() {
String DSL = "[when]String is \"{value}\"=SomeFact(value==\"{value}\")";
StringReader dslSrc = new StringReader(DSL);
expander = new DefaultExpander(dslSrc);
}
public void testExpandNoSpaces() {
String result = expander.expand("when", "String is \"blah\"");
assertEquals("SomeFact(value==\"blah\")", result);
}
public void testExpandWithLeadingSpace() {
String result = expander.expand("when", "String is \" blah\"");
assertEquals("SomeFact(value==\" blah\")", result);
}
public void testExpandWithMultipleLeadingSpaces() {
String result = expander.expand("when", "String is \" blah\"");
assertEquals("SomeFact(value==\" blah\")", result);
}
public void testExpandWithTrailingSpace() {
String result = expander.expand("when", "String is \" blah \"");
assertEquals("SomeFact(value==\"blah \")", result);
}
public void testExpandWithMultipleTrailingSpaces() {
String result = expander.expand("when", "String is \"blah \"");
assertEquals("SomeFact(value==\"blah \")", result);
}
public void testExpandWithInternalSpace() {
String result = expander.expand("when", "String is \"bl ah\"");
assertEquals("SomeFact(value==\"bl ah\")", result);
}
public void testExpandWithMultipleInternalSpaces() {
String result = expander.expand("when", "String is \"bl ah\"");
assertEquals("SomeFact(value==\"bl ah\")", result);
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
19 years, 5 months
[JBoss JIRA] Created: (JBAS-3431) AuthorizationInterceptor throwing ArrayIndexOutOfBoundsException
by Anil Saldhana (JIRA)
AuthorizationInterceptor throwing ArrayIndexOutOfBoundsException
----------------------------------------------------------------
Key: JBAS-3431
URL: http://jira.jboss.com/jira/browse/JBAS-3431
Project: JBoss Application Server
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: JMX, Security
Affects Versions: JBossAS-4.0.4.GA
Reporter: Anil Saldhana
Assigned To: Anil Saldhana
Fix For: JBossAS-5.0.0.Beta, JBossAS-4.0.5.CR1
As Originally reported in JBJMX-97, the user says:
==========================================================================================
I have secured the jmx-invoker-service using JAAS and the standard UsersRolesLoginModule. I am able to authenticate (basic authentication) through the web UI and manage the console using the same login config.
I am getting a remote connection to the JMX server from an InitialContext that is populated with the user name and password:
env.put(Context.SECURITY_PRINCIPAL, userName);
env.put(Context.SECURITY_CREDENTIALS, password);
Then I look up the MBeanServerConnection and try to get the MBeanInfo
MBeanServerConnection server = lookup("jmx/invoker/RMIAdaptor", MBeanServerConnection.class);
ObjectName name = new ObjectName(theName);
MBeanInfo info = server.getMBeanInfo(name);
At this point the server throws an ArrayIndexOutOfBoundsException from org.jboss.jmx.connector.invoker.AuthorizationInterceptor line 107.
If I try and set an attribute:
server.setAttribute(name, new Attribute("searchText", searchText));
I get instead at the same line:
java.lang.ClassCastException: javax.management.Attribute
at org.jboss.jmx.connector.invoker.AuthorizationInterceptor.invoke(AuthorizationInterceptor.java:107)
at org.jboss.jmx.connector.invoker.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:108)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
==========================================================================================
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
19 years, 5 months