Hi,
I'm having an issue trying to read an inputstream data in my aspect and then
setting the input stream object to a new object. This doesn't work
Here is the sample code
public class AspectSampleMain {
public static void main(String[] args) {
// TODO Auto-generated method stub
String test = "hello world
askdjlasdkjaldkjasldkjalsdkjaslkdjalskjdslakjd dsjalkjd";
ByteArrayInputStream bais = new
ByteArrayInputStream(test.getBytes());
InputStream is = bais;
bar(is);
}
public static void bar(InputStream is){
String l = readContent(is);
System.out.println(l); // l is blank this is wrong because is
has been read.
}
}
Here is my aspect
public aspect AspectSample {
pointcut sample(java.io.InputStream is):
execution(* AspectSampleMain.bar( .. ))
&& args(is);
before (java.io.InputStream is):sample(is){
String l = readContent(is);
ByteArrayInputStream bais = new
ByteArrayInputStream(l.getBytes());
is = bais;
}
}
This does not work as the "is" does not get set to bais after the aspect
returns to the bar() code. So the input stream has been read and can't be
re-read again.
How do I get around this.
Thanks
Al
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users