-
Bug
-
Resolution: Fixed
-
P4
-
8, 9, 10
-
b01
-
x86_64
-
generic
-
Verified
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
The serialization and deserialization of a pattern that contains a (?idmsuxU-idmsuxU) - construct does not work.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Compile the pattern "a(?-i)b" with Pattern.CASE_INSENSITIVE
2) Serialize and deserialize it using ObjectOutput- and ObjectInputStream
3) The pattern should match against the input "Ab" but does not
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The pattern should match against the input "Ab"
ACTUAL -
The pattern didn't match against the input "Ab"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.regex.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class RegexBug4 {
public static void main(String [] args) {
Pattern p = Pattern.compile("a(?-i)b", Pattern.CASE_INSENSITIVE );
System.out.println(p.matcher("Ab").matches() );
System.out.println(p.matcher("AB").matches() );
p = serializeAndDeserialize(p);
System.out.println(p.matcher("Ab").matches() );
System.out.println(p.matcher("AB").matches() );
}
private static Pattern serializeAndDeserialize(Pattern pattern){
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(pattern);
oos.close();
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
Pattern serializedPattern = (Pattern) ois.readObject();
ois.close();
return serializedPattern;
} catch( IOException | ClassNotFoundException ioe) {
ioe.printStackTrace();
return null;
}
}
}
---------- END SOURCE ----------
A DESCRIPTION OF THE PROBLEM :
The serialization and deserialization of a pattern that contains a (?idmsuxU-idmsuxU) - construct does not work.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Compile the pattern "a(?-i)b" with Pattern.CASE_INSENSITIVE
2) Serialize and deserialize it using ObjectOutput- and ObjectInputStream
3) The pattern should match against the input "Ab" but does not
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The pattern should match against the input "Ab"
ACTUAL -
The pattern didn't match against the input "Ab"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.regex.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class RegexBug4 {
public static void main(String [] args) {
Pattern p = Pattern.compile("a(?-i)b", Pattern.CASE_INSENSITIVE );
System.out.println(p.matcher("Ab").matches() );
System.out.println(p.matcher("AB").matches() );
p = serializeAndDeserialize(p);
System.out.println(p.matcher("Ab").matches() );
System.out.println(p.matcher("AB").matches() );
}
private static Pattern serializeAndDeserialize(Pattern pattern){
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(pattern);
oos.close();
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
Pattern serializedPattern = (Pattern) ois.readObject();
ois.close();
return serializedPattern;
} catch( IOException | ClassNotFoundException ioe) {
ioe.printStackTrace();
return null;
}
}
}
---------- END SOURCE ----------