You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "robert Cook (JIRA)" <ji...@apache.org> on 2010/01/26 21:26:34 UTC
[jira] Created: (HADOOP-6512) Complex Writable classes are not
thread safe
Complex Writable classes are not thread safe
--------------------------------------------
Key: HADOOP-6512
URL: https://issues.apache.org/jira/browse/HADOOP-6512
Project: Hadoop Common
Issue Type: Bug
Components: io
Affects Versions: 0.20.1
Environment: hadoop 20.1, java 1.6.0_17, fedora
Reporter: robert Cook
While SequenceFile methods are properly "synchronized", the complex Writable classes are not thread safe.
e.g. ArrayWritable, interleaved in... calls by different threads will scramble input
public void readFields(DataInput in) throws IOException {
values = new Writable[in.readInt()]; // construct values
for (int i = 0; i < values.length; i++) {
Writable value = WritableFactories.newInstance(valueClass);
value.readFields(in); // read a value
values[i] = value; // store it in values
}
}
Please add synchronized prefixes. Not needed for simple types.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (HADOOP-6512) Complex Writable classes are not
thread safe
Posted by "Chris Douglas (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HADOOP-6512?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Chris Douglas resolved HADOOP-6512.
-----------------------------------
Resolution: Invalid
I agree with Todd; the caller is responsible for thread safety.
> Complex Writable classes are not thread safe
> --------------------------------------------
>
> Key: HADOOP-6512
> URL: https://issues.apache.org/jira/browse/HADOOP-6512
> Project: Hadoop Common
> Issue Type: Bug
> Components: io
> Affects Versions: 0.20.1
> Environment: hadoop 20.1, java 1.6.0_17, fedora
> Reporter: robert Cook
>
> While SequenceFile methods are properly "synchronized", the complex Writable classes are not thread safe.
> e.g. ArrayWritable, interleaved in... calls by different threads will scramble input
> public void readFields(DataInput in) throws IOException {
> values = new Writable[in.readInt()]; // construct values
> for (int i = 0; i < values.length; i++) {
> Writable value = WritableFactories.newInstance(valueClass);
> value.readFields(in); // read a value
> values[i] = value; // store it in values
> }
> }
> Please add synchronized prefixes. Not needed for simple types.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HADOOP-6512) Complex Writable classes are not
thread safe
Posted by "Owen O'Malley (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HADOOP-6512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12805203#action_12805203 ]
Owen O'Malley commented on HADOOP-6512:
---------------------------------------
I agree with Todd too. Like the java.util Container classes, it is better for the calling context to enforce the proper level of locking.
> Complex Writable classes are not thread safe
> --------------------------------------------
>
> Key: HADOOP-6512
> URL: https://issues.apache.org/jira/browse/HADOOP-6512
> Project: Hadoop Common
> Issue Type: Bug
> Components: io
> Affects Versions: 0.20.1
> Environment: hadoop 20.1, java 1.6.0_17, fedora
> Reporter: robert Cook
>
> While SequenceFile methods are properly "synchronized", the complex Writable classes are not thread safe.
> e.g. ArrayWritable, interleaved in... calls by different threads will scramble input
> public void readFields(DataInput in) throws IOException {
> values = new Writable[in.readInt()]; // construct values
> for (int i = 0; i < values.length; i++) {
> Writable value = WritableFactories.newInstance(valueClass);
> value.readFields(in); // read a value
> values[i] = value; // store it in values
> }
> }
> Please add synchronized prefixes. Not needed for simple types.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HADOOP-6512) Complex Writable classes are not
thread safe
Posted by "Todd Lipcon (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HADOOP-6512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12805189#action_12805189 ]
Todd Lipcon commented on HADOOP-6512:
-------------------------------------
Do you think it should be synchronized on the DataInput or on the writable itself? It seems to me it would be the responsibility of the one calling read to ensure synchronization, not the writable's.
> Complex Writable classes are not thread safe
> --------------------------------------------
>
> Key: HADOOP-6512
> URL: https://issues.apache.org/jira/browse/HADOOP-6512
> Project: Hadoop Common
> Issue Type: Bug
> Components: io
> Affects Versions: 0.20.1
> Environment: hadoop 20.1, java 1.6.0_17, fedora
> Reporter: robert Cook
>
> While SequenceFile methods are properly "synchronized", the complex Writable classes are not thread safe.
> e.g. ArrayWritable, interleaved in... calls by different threads will scramble input
> public void readFields(DataInput in) throws IOException {
> values = new Writable[in.readInt()]; // construct values
> for (int i = 0; i < values.length; i++) {
> Writable value = WritableFactories.newInstance(valueClass);
> value.readFields(in); // read a value
> values[i] = value; // store it in values
> }
> }
> Please add synchronized prefixes. Not needed for simple types.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.