You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by bu...@apache.org on 2001/11/29 18:05:02 UTC
DO NOT REPLY [Bug 5184] New: -
ComponentUtil.setWriteOnceObject broken
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5184>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5184
ComponentUtil.setWriteOnceObject broken
Summary: ComponentUtil.setWriteOnceObject broken
Product: Avalon
Version: unspecified
Platform: Other
OS/Version: Other
Status: NEW
Severity: Major
Priority: Other
Component: Framework
AssignedTo: avalon-dev@jakarta.apache.org
ReportedBy: leo.sutic@inspireinfrastructure.com
The setWriteOnceObject method is broken.
public static final void setWriteOnceObject( Object source, final Object
value, final String message )
{
if ( null == source )
{
source = value;
}
else
{
throw new IllegalStateException( message );
}
}
The source = value assignment has no effect whatsoever. As it is now,
setWriteOnceObject is equivalent to:
public static final void setWriteOnceObject( Object source, final String
message )
{
if ( null != source )
{
throw new IllegalStateException( message );
}
}
Test case:
import org.apache.avalon.framework.ComponentUtil;
public class TestComponentUtil {
public static void main (String args[]) throws Exception {
String source = null;
String value = "valued";
String message = "Already set.";
// Prints "null".
System.out.println (source);
// Prints attempts to set source to "valued"
ComponentUtil.setWriteOnceObject (source, value, message);
// This should print "valued", but prints "null".
System.out.println (source);
// Set it again. This should fail, but since source hasn't been
// set, it passes.
ComponentUtil.setWriteOnceObject (source, value, message);
// This should print "valued", but prints "null".
System.out.println (source);
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>