下面列出了java.io.ObjectInputValidation#java.io.NotActiveException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Override the actions of the final method "defaultWriteObject()"
* in ObjectOutputStream.
* @since JDK1.1.6
*/
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
try {
if (currentObject == null || currentClassDesc == null)
// XXX I18N, Logging needed.
throw new NotActiveException("defaultWriteObjectDelegate");
ObjectStreamField[] fields =
currentClassDesc.getFieldsNoCopy();
if (fields.length > 0) {
outputClassFields(currentObject, currentClassDesc.forClass(),
fields);
}
} catch(IOException ioe) {
bridge.throwException(ioe);
}
}
public ObjectInputStream.GetField readFields()
throws IOException, ClassNotFoundException, NotActiveException {
HashMap fieldValueMap = new HashMap();
// We were treating readFields same as defaultReadObject. It is
// incorrect if the state is readOptionalData. If this line
// is uncommented, it will throw a stream corrupted exception.
// _REVISIT_: The ideal fix would be to add a new state. In
// writeObject user may do one of the following
// 1. Call defaultWriteObject()
// 2. Put out optional fields
// 3. Call writeFields
// We have the state defined for (1) and (2) but not for (3), so
// we should ideally introduce a new state for 3 and have the
// beginDefaultReadObject do nothing.
//readObjectState.beginDefaultReadObject(this);
readFields(fieldValueMap);
readObjectState.endDefaultReadObject(this);
return new HookGetFields(fieldValueMap);
}
/**
* Override the actions of the final method "defaultWriteObject()"
* in ObjectOutputStream.
* @since JDK1.1.6
*/
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
try {
if (currentObject == null || currentClassDesc == null)
// XXX I18N, Logging needed.
throw new NotActiveException("defaultWriteObjectDelegate");
ObjectStreamField[] fields =
currentClassDesc.getFieldsNoCopy();
if (fields.length > 0) {
outputClassFields(currentObject, currentClassDesc.forClass(),
fields);
}
} catch(IOException ioe) {
bridge.throwException(ioe);
}
}
public ObjectInputStream.GetField readFields()
throws IOException, ClassNotFoundException, NotActiveException {
HashMap fieldValueMap = new HashMap();
// We were treating readFields same as defaultReadObject. It is
// incorrect if the state is readOptionalData. If this line
// is uncommented, it will throw a stream corrupted exception.
// _REVISIT_: The ideal fix would be to add a new state. In
// writeObject user may do one of the following
// 1. Call defaultWriteObject()
// 2. Put out optional fields
// 3. Call writeFields
// We have the state defined for (1) and (2) but not for (3), so
// we should ideally introduce a new state for 3 and have the
// beginDefaultReadObject do nothing.
//readObjectState.beginDefaultReadObject(this);
readFields(fieldValueMap);
readObjectState.endDefaultReadObject(this);
return new HookGetFields(fieldValueMap);
}
/**
* Override the actions of the final method "defaultWriteObject()"
* in ObjectOutputStream.
* @since JDK1.1.6
*/
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
try {
if (currentObject == null || currentClassDesc == null)
// XXX I18N, Logging needed.
throw new NotActiveException("defaultWriteObjectDelegate");
ObjectStreamField[] fields =
currentClassDesc.getFieldsNoCopy();
if (fields.length > 0) {
outputClassFields(currentObject, currentClassDesc.forClass(),
fields);
}
} catch(IOException ioe) {
bridge.throwException(ioe);
}
}
public ObjectInputStream.GetField readFields()
throws IOException, ClassNotFoundException, NotActiveException {
HashMap fieldValueMap = new HashMap();
// We were treating readFields same as defaultReadObject. It is
// incorrect if the state is readOptionalData. If this line
// is uncommented, it will throw a stream corrupted exception.
// _REVISIT_: The ideal fix would be to add a new state. In
// writeObject user may do one of the following
// 1. Call defaultWriteObject()
// 2. Put out optional fields
// 3. Call writeFields
// We have the state defined for (1) and (2) but not for (3), so
// we should ideally introduce a new state for 3 and have the
// beginDefaultReadObject do nothing.
//readObjectState.beginDefaultReadObject(this);
readFields(fieldValueMap);
readObjectState.endDefaultReadObject(this);
return new HookGetFields(fieldValueMap);
}
/**
* Override the actions of the final method "defaultWriteObject()"
* in ObjectOutputStream.
* @since JDK1.1.6
*/
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
try {
if (currentObject == null || currentClassDesc == null)
// XXX I18N, Logging needed.
throw new NotActiveException("defaultWriteObjectDelegate");
ObjectStreamField[] fields =
currentClassDesc.getFieldsNoCopy();
if (fields.length > 0) {
outputClassFields(currentObject, currentClassDesc.forClass(),
fields);
}
} catch(IOException ioe) {
bridge.throwException(ioe);
}
}
public ObjectInputStream.GetField readFields()
throws IOException, ClassNotFoundException, NotActiveException {
HashMap fieldValueMap = new HashMap();
// We were treating readFields same as defaultReadObject. It is
// incorrect if the state is readOptionalData. If this line
// is uncommented, it will throw a stream corrupted exception.
// _REVISIT_: The ideal fix would be to add a new state. In
// writeObject user may do one of the following
// 1. Call defaultWriteObject()
// 2. Put out optional fields
// 3. Call writeFields
// We have the state defined for (1) and (2) but not for (3), so
// we should ideally introduce a new state for 3 and have the
// beginDefaultReadObject do nothing.
//readObjectState.beginDefaultReadObject(this);
readFields(fieldValueMap);
readObjectState.endDefaultReadObject(this);
return new HookGetFields(fieldValueMap);
}
/**
* Override the actions of the final method "defaultWriteObject()"
* in ObjectOutputStream.
* @since JDK1.1.6
*/
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
try {
if (currentObject == null || currentClassDesc == null)
// XXX I18N, Logging needed.
throw new NotActiveException("defaultWriteObjectDelegate");
ObjectStreamField[] fields =
currentClassDesc.getFieldsNoCopy();
if (fields.length > 0) {
outputClassFields(currentObject, currentClassDesc.forClass(),
fields);
}
} catch(IOException ioe) {
bridge.throwException(ioe);
}
}
public ObjectInputStream.GetField readFields()
throws IOException, ClassNotFoundException, NotActiveException {
HashMap fieldValueMap = new HashMap();
// We were treating readFields same as defaultReadObject. It is
// incorrect if the state is readOptionalData. If this line
// is uncommented, it will throw a stream corrupted exception.
// _REVISIT_: The ideal fix would be to add a new state. In
// writeObject user may do one of the following
// 1. Call defaultWriteObject()
// 2. Put out optional fields
// 3. Call writeFields
// We have the state defined for (1) and (2) but not for (3), so
// we should ideally introduce a new state for 3 and have the
// beginDefaultReadObject do nothing.
//readObjectState.beginDefaultReadObject(this);
readFields(fieldValueMap);
readObjectState.endDefaultReadObject(this);
return new HookGetFields(fieldValueMap);
}
/**
* Override the actions of the final method "defaultWriteObject()"
* in ObjectOutputStream.
* @since JDK1.1.6
*/
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
try {
if (currentObject == null || currentClassDesc == null)
// XXX I18N, Logging needed.
throw new NotActiveException("defaultWriteObjectDelegate");
ObjectStreamField[] fields =
currentClassDesc.getFieldsNoCopy();
if (fields.length > 0) {
outputClassFields(currentObject, currentClassDesc.forClass(),
fields);
}
} catch(IOException ioe) {
bridge.throwException(ioe);
}
}
public ObjectInputStream.GetField readFields()
throws IOException, ClassNotFoundException, NotActiveException {
HashMap fieldValueMap = new HashMap();
// We were treating readFields same as defaultReadObject. It is
// incorrect if the state is readOptionalData. If this line
// is uncommented, it will throw a stream corrupted exception.
// _REVISIT_: The ideal fix would be to add a new state. In
// writeObject user may do one of the following
// 1. Call defaultWriteObject()
// 2. Put out optional fields
// 3. Call writeFields
// We have the state defined for (1) and (2) but not for (3), so
// we should ideally introduce a new state for 3 and have the
// beginDefaultReadObject do nothing.
//readObjectState.beginDefaultReadObject(this);
readFields(fieldValueMap);
readObjectState.endDefaultReadObject(this);
return new HookGetFields(fieldValueMap);
}
/**
* Override the actions of the final method "defaultWriteObject()"
* in ObjectOutputStream.
* @since JDK1.1.6
*/
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
try {
if (currentObject == null || currentClassDesc == null)
// XXX I18N, Logging needed.
throw new NotActiveException("defaultWriteObjectDelegate");
ObjectStreamField[] fields =
currentClassDesc.getFieldsNoCopy();
if (fields.length > 0) {
outputClassFields(currentObject, currentClassDesc.forClass(),
fields);
}
} catch(IOException ioe) {
bridge.throwException(ioe);
}
}
public ObjectInputStream.GetField readFields()
throws IOException, ClassNotFoundException, NotActiveException {
HashMap fieldValueMap = new HashMap();
// We were treating readFields same as defaultReadObject. It is
// incorrect if the state is readOptionalData. If this line
// is uncommented, it will throw a stream corrupted exception.
// _REVISIT_: The ideal fix would be to add a new state. In
// writeObject user may do one of the following
// 1. Call defaultWriteObject()
// 2. Put out optional fields
// 3. Call writeFields
// We have the state defined for (1) and (2) but not for (3), so
// we should ideally introduce a new state for 3 and have the
// beginDefaultReadObject do nothing.
//readObjectState.beginDefaultReadObject(this);
readFields(fieldValueMap);
readObjectState.endDefaultReadObject(this);
return new HookGetFields(fieldValueMap);
}
/**
* Override the actions of the final method "defaultWriteObject()"
* in ObjectOutputStream.
* @since JDK1.1.6
*/
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
try {
if (currentObject == null || currentClassDesc == null)
// XXX I18N, Logging needed.
throw new NotActiveException("defaultWriteObjectDelegate");
ObjectStreamField[] fields =
currentClassDesc.getFieldsNoCopy();
if (fields.length > 0) {
outputClassFields(currentObject, currentClassDesc.forClass(),
fields);
}
} catch(IOException ioe) {
bridge.throwException(ioe);
}
}
public ObjectInputStream.GetField readFields()
throws IOException, ClassNotFoundException, NotActiveException {
HashMap fieldValueMap = new HashMap();
// We were treating readFields same as defaultReadObject. It is
// incorrect if the state is readOptionalData. If this line
// is uncommented, it will throw a stream corrupted exception.
// _REVISIT_: The ideal fix would be to add a new state. In
// writeObject user may do one of the following
// 1. Call defaultWriteObject()
// 2. Put out optional fields
// 3. Call writeFields
// We have the state defined for (1) and (2) but not for (3), so
// we should ideally introduce a new state for 3 and have the
// beginDefaultReadObject do nothing.
//readObjectState.beginDefaultReadObject(this);
readFields(fieldValueMap);
readObjectState.endDefaultReadObject(this);
return new HookGetFields(fieldValueMap);
}
/**
* Override the actions of the final method "defaultWriteObject()"
* in ObjectOutputStream.
* @since JDK1.1.6
*/
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
try {
if (currentObject == null || currentClassDesc == null)
// XXX I18N, Logging needed.
throw new NotActiveException("defaultWriteObjectDelegate");
ObjectStreamField[] fields =
currentClassDesc.getFieldsNoCopy();
if (fields.length > 0) {
outputClassFields(currentObject, currentClassDesc.forClass(),
fields);
}
} catch(IOException ioe) {
bridge.throwException(ioe);
}
}
public ObjectInputStream.GetField readFields()
throws IOException, ClassNotFoundException, NotActiveException {
HashMap fieldValueMap = new HashMap();
// We were treating readFields same as defaultReadObject. It is
// incorrect if the state is readOptionalData. If this line
// is uncommented, it will throw a stream corrupted exception.
// _REVISIT_: The ideal fix would be to add a new state. In
// writeObject user may do one of the following
// 1. Call defaultWriteObject()
// 2. Put out optional fields
// 3. Call writeFields
// We have the state defined for (1) and (2) but not for (3), so
// we should ideally introduce a new state for 3 and have the
// beginDefaultReadObject do nothing.
//readObjectState.beginDefaultReadObject(this);
readFields(fieldValueMap);
readObjectState.endDefaultReadObject(this);
return new HookGetFields(fieldValueMap);
}
/**
* Override the actions of the final method "defaultWriteObject()"
* in ObjectOutputStream.
* @since JDK1.1.6
*/
public final void defaultWriteObjectDelegate()
/* throws IOException */
{
try {
if (currentObject == null || currentClassDesc == null)
// XXX I18N, Logging needed.
throw new NotActiveException("defaultWriteObjectDelegate");
ObjectStreamField[] fields =
currentClassDesc.getFieldsNoCopy();
if (fields.length > 0) {
outputClassFields(currentObject, currentClassDesc.forClass(),
fields);
}
} catch(IOException ioe) {
bridge.throwException(ioe);
}
}
public ObjectInputStream.GetField readFields()
throws IOException, ClassNotFoundException, NotActiveException {
HashMap fieldValueMap = new HashMap();
// We were treating readFields same as defaultReadObject. It is
// incorrect if the state is readOptionalData. If this line
// is uncommented, it will throw a stream corrupted exception.
// _REVISIT_: The ideal fix would be to add a new state. In
// writeObject user may do one of the following
// 1. Call defaultWriteObject()
// 2. Put out optional fields
// 3. Call writeFields
// We have the state defined for (1) and (2) but not for (3), so
// we should ideally introduce a new state for 3 and have the
// beginDefaultReadObject do nothing.
//readObjectState.beginDefaultReadObject(this);
readFields(fieldValueMap);
readObjectState.endDefaultReadObject(this);
return new HookGetFields(fieldValueMap);
}
public SslFilter getSslFilter() throws Exception {
if (keystoreFile == null || truststoreFile == null) {
throw new NotActiveException("Keystore or truststore are null");
}
SSLContext context = getSslContext();
if (context == null) {
throw new NotActiveException("SSLContext is null");
}
// create the ssl filter using server mode
SslFilter sslFilter = new SslFilter(context);
if (cipherSuites != null) {
sslFilter.setEnabledCipherSuites(cipherSuites);
}
if (protocols != null) {
if (log.isDebugEnabled()) {
log.debug("Using these protocols: {}", Arrays.toString(protocols));
}
sslFilter.setEnabledProtocols(protocols);
}
return sslFilter;
}
public void test_putFields() throws Exception {
/*
* "SerializableTestHelper" is an object created for these tests with
* two fields (Strings) and simple implementations of readObject and
* writeObject which simply read and write the first field but not the
* second one.
*/
SerializableTestHelper sth;
try {
oos.putFields();
fail("Test 1: NotActiveException expected.");
} catch (NotActiveException e) {
// Expected.
}
oos.writeObject(new SerializableTestHelper("Gabba", "Jabba"));
oos.flush();
ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
sth = (SerializableTestHelper) (ois.readObject());
assertEquals("Test 2: readFields or writeFields failed; first field not set.",
"Gabba", sth.getText1());
assertNull("Test 3: readFields or writeFields failed; second field should not have been set.",
sth.getText2());
}
public void writeFields()
throws IOException {
writeObjectState.defaultWriteObject(this);
if (putFields != null) {
putFields.write(this);
} else {
throw new NotActiveException("no current PutField object");
}
}
public void defaultReadObject()
throws IOException, ClassNotFoundException, NotActiveException
{
readObjectState.beginDefaultReadObject(this);
defaultReadObjectDelegate();
readObjectState.endDefaultReadObject(this);
}
public void writeFields()
throws IOException {
writeObjectState.defaultWriteObject(this);
if (putFields != null) {
putFields.write(this);
} else {
throw new NotActiveException("no current PutField object");
}
}
public void defaultReadObject()
throws IOException, ClassNotFoundException, NotActiveException
{
readObjectState.beginDefaultReadObject(this);
defaultReadObjectDelegate();
readObjectState.endDefaultReadObject(this);
}
public void writeFields()
throws IOException {
writeObjectState.defaultWriteObject(this);
if (putFields != null) {
putFields.write(this);
} else {
throw new NotActiveException("no current PutField object");
}
}
public void defaultReadObject()
throws IOException, ClassNotFoundException, NotActiveException
{
readObjectState.beginDefaultReadObject(this);
defaultReadObjectDelegate();
readObjectState.endDefaultReadObject(this);
}
public void writeFields()
throws IOException {
writeObjectState.defaultWriteObject(this);
if (putFields != null) {
putFields.write(this);
} else {
throw new NotActiveException("no current PutField object");
}
}
public void defaultReadObject()
throws IOException, ClassNotFoundException, NotActiveException
{
readObjectState.beginDefaultReadObject(this);
defaultReadObjectDelegate();
readObjectState.endDefaultReadObject(this);
}