Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.settings/
/site-content/
/.idea/
*.iml

# NetBeans files
nb-configuration.xml
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.marshalling</groupId>
<artifactId>jboss-marshalling</artifactId>
<version>2.0.12.Final</version>
<scope>test</scope>
</dependency>
Comment on lines +106 to +111

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
Expand Down
33 changes: 17 additions & 16 deletions src/main/java/org/apache/commons/beanutils/DynaProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
* for use by mapped and iterated properties.
* A mapped or iterated property may choose to indicate the type it expects.
* The DynaBean implementation may choose to enforce this type on its entries.
* Alternatively, an implementatin may choose to ignore this property.
* All keys for maps must be of type String so no meta data is needed for map keys.</p>
* Alternatively, an implementation may choose to ignore this property.
* All keys for maps must be of type String so no metadata is needed for map keys.</p>
*
*/

public class DynaProperty implements Serializable {

private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 2L;
/*
* There are issues with serializing primitive class types on certain JVM versions
* (including java 1.3).
Expand Down Expand Up @@ -111,7 +111,7 @@ public DynaProperty(final String name, final Class<?> type, final Class<?> conte

/**
* Checks this instance against the specified Object for equality. Overrides the
* default refererence test for equality provided by {@link Object#equals(Object)}
* default reference test for equality provided by {@link Object#equals(Object)}
*
* @param obj The object to compare to
* @return {@code true} if object is a dyna property with the same name
Expand All @@ -121,9 +121,7 @@ public DynaProperty(final String name, final Class<?> type, final Class<?> conte
@Override
public boolean equals(final Object obj) {

boolean result = false;

result = obj == this;
boolean result = obj == this;

if (!result && obj instanceof DynaProperty) {
final DynaProperty that = (DynaProperty) obj;
Expand All @@ -145,7 +143,7 @@ public boolean equals(final Object obj) {
* Therefore, this field <strong>must not be serialized using the standard methods</strong>.</p>
*
* @return The Class for the content type if this is an indexed {@code DynaProperty}
* and this feature is supported. Otherwise null.
* and this feature is supported. Otherwise, null.
*/
public Class<?> getContentType() {
return contentType;
Expand Down Expand Up @@ -247,8 +245,7 @@ private Class<?> readAnyClass(final ObjectInputStream in) throws IOException, Cl
default:
// something's gone wrong
throw new StreamCorruptedException(
"Invalid primitive type. "
+ "Check version of beanutils used to serialize is compatible.");
"Invalid primitive type. Check version of beanutils used to serialize is compatible.");

}
}
Expand All @@ -262,12 +259,14 @@ private Class<?> readAnyClass(final ObjectInputStream in) throws IOException, Cl
* @throws ClassNotFoundException Class of a serialized object cannot be found.
*/
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
// read default first (as defined by the Java Object Serialization Specification)
in.defaultReadObject();

// read custom values
this.type = readAnyClass(in);
if (isMapped() || isIndexed()) {
this.contentType = readAnyClass(in);
}
// read other values
in.defaultReadObject();
}
Comment on lines 261 to 270

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just bump serialVersionUID, as supporting both serialization strategies is non-trivial to impossible.


/**
Expand Down Expand Up @@ -333,11 +332,13 @@ private void writeAnyClass(final Class<?> clazz, final ObjectOutputStream out) t
* @throws IOException if I/O errors occur while writing to the underlying stream.
*/
private void writeObject(final ObjectOutputStream out) throws IOException {
writeAnyClass(this.type,out);
// write out default first (as defined by the Java Object Serialization Specification)
out.defaultWriteObject();

// write custom values
writeAnyClass(this.type, out);
if (isMapped() || isIndexed()) {
writeAnyClass(this.contentType,out);
writeAnyClass(this.contentType, out);
}
// write out other values
out.defaultWriteObject();
}
Comment on lines 334 to 343

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writeObject() wouldn't need to be adapted, as we want to write the new format always.

However, I'll just bump serialVersionUID, as supporting both serialization strategies is non-trivial to impossible.

}
Loading
Loading