Skip to content
Permalink
Browse files
Corrections to reading start of CMSFv2 valuetype
  • Loading branch information
ngmr committed May 7, 2015
1 parent 0dd133f commit 67752264143d32781ce58218dc446ac6921d219e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
@@ -155,7 +155,7 @@ void readExternal(Externalizable ext) {
}

@Override
protected Object readObjectOverride() {
protected final Object readObjectOverride() {
throw newException();
}
}
@@ -1,7 +1,6 @@
package org.apache.yoko.rmi.impl;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
@@ -11,7 +10,7 @@
import org.omg.CORBA.INTERNAL;
import org.omg.CORBA.MARSHAL;

public class CustomMarshaledObjectReader extends DelegatingObjectReader {
public final class CustomMarshaledObjectReader extends DelegatingObjectReader {
private enum State {
UNINITIALISED, BEFORE_CUSTOM_DATA, IN_CUSTOM_DATA, CLOSED;
private static final Map<State, Set<State>> TRANSITIONS;
@@ -93,12 +92,17 @@ public void close() throws IOException {
}
}

@Override
protected final Object readObjectOverride() throws ClassNotFoundException, IOException {
return super.readObjectOverride0();
}

/**
* This class handles reading the defaultWriteObject() data,
* and prepares its outer instance when the custom data is
* first read.
*/
private class DefaultWriteObjectReader extends DelegatingObjectReaderWithBeforeReadHook {
private final class DefaultWriteObjectReader extends DelegatingObjectReaderWithBeforeReadHook {

private boolean allowDefaultRead = true;

@@ -112,10 +116,20 @@ public void defaultReadObject() throws IOException, ClassNotFoundException {
allowDefaultRead = false;
CustomMarshaledObjectReader.this.objectReader.defaultReadObject();
} else {
throw new IllegalStateException("defaultReadObject() must not be called more than once");
throw new IllegalStateException("defaultReadObject() or readFields() must not be called more than once");
}
}

@Override
public GetField readFields() throws IOException ,ClassNotFoundException {
if (allowDefaultRead) {
allowDefaultRead = false;
return CustomMarshaledObjectReader.this.objectReader.readFields();
} else {
throw new IllegalStateException("readFields() or defaultReadObject() must not be called more than once");
}
};

@Override
void beforeRead() {
try {
@@ -22,7 +22,7 @@ void delegateTo(ObjectReader delegate) {
// ONLY DELEGATE METHODS BELOW HERE //
//////////////////////////////////////

protected final Object readObjectOverride() throws ClassNotFoundException, IOException {
final Object readObjectOverride0() throws ClassNotFoundException, IOException {
return delegate.readObjectOverride();
}

@@ -4,7 +4,6 @@
import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.NotActiveException;
import java.io.ObjectInputStream;
import java.io.ObjectInputValidation;
import java.rmi.Remote;

@@ -50,14 +49,10 @@ public Object readUnshared() throws IOException, ClassNotFoundException {
beforeRead();
return delegate.readUnshared();
}
public void defaultReadObject() throws IOException, ClassNotFoundException {
beforeRead();
delegate.defaultReadObject();
}
public GetField readFields() throws IOException, ClassNotFoundException {
beforeRead();
return delegate.readFields();
}

public abstract void defaultReadObject() throws IOException, ClassNotFoundException;
public abstract GetField readFields() throws IOException, ClassNotFoundException;

public void registerValidation(ObjectInputValidation obj, int prio) throws NotActiveException, InvalidObjectException {
delegate.registerValidation(obj, prio);
}
@@ -136,6 +131,11 @@ public String readUTF() throws IOException {
beforeRead();
return delegate.readUTF();
}
@Override
protected final Object readObjectOverride() throws ClassNotFoundException ,IOException {
beforeRead();
return delegate.readObjectOverride();
};

///////////////////////////////////////
// delegate methods for ObjectReader //

0 comments on commit 6775226

Please sign in to comment.