Skip to content

Commit

Permalink
[JBRULES-3436] fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mariofusco committed Apr 6, 2012
1 parent a751c8a commit f843614
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Expand Up @@ -113,7 +113,7 @@ public int compare(JavaBlockDescr o1,
int lastAdded = 0;

for (JavaBlockDescr block : blocks) {
if (block.getEnd() == 0) {
if (block.getEnd() == 0 || block.getEnd() > originalCode.length() ) {
// do nothing, it was incorrectly parsed, but this error should be picked up else where
continue;
}
Expand Down
Expand Up @@ -10103,4 +10103,22 @@ public void testNoMvelSyntaxInFunctions() throws Exception {

assertTrue(kbuilder.hasErrors());
}

@Test
public void testMissingClosingBraceOnModify() throws Exception {
// JBRULES-3436
String str = "package org.drools.test;\n" +
"import org.drools.*\n" +
"rule R1 when\n" +
" $p : Person( )" +
" $c : Cheese( )" +
"then\n" +
" modify($p) { setCheese($c) ;\n" +
"end\n";

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newByteArrayResource(str.getBytes()), ResourceType.DRL );

assertTrue( kbuilder.hasErrors() );
}
}

0 comments on commit f843614

Please sign in to comment.