use of java.io.InvalidObjectException in project tomee by apache.
the class JndiEncArtifact method readResolve.
public Object readResolve() throws ObjectStreamException {
final ThreadContext thrdCntx = ThreadContext.getThreadContext();
final BeanContext deployment = thrdCntx.getBeanContext();
final Context cntx = deployment.getJndiEnc();
try {
final Object obj = cntx.lookup(path);
if (obj == null) {
throw new InvalidObjectException("JNDI ENC context reference could not be properly resolved when bean instance was activated");
}
return obj;
} catch (final NamingException e) {
throw (InvalidObjectException) new InvalidObjectException("JNDI ENC context reference could not be properly resolved due to a JNDI exception, when bean instance was activated").initCause(e);
}
}
use of java.io.InvalidObjectException in project ignite by apache.
the class GridLoggerProxy method readResolve.
/**
* Reconstructs object on unmarshalling.
*
* @return Reconstructed object.
* @throws ObjectStreamException Thrown in case of unmarshalling error.
*/
protected Object readResolve() throws ObjectStreamException {
try {
IgniteBiTuple<String, Object> t = stash.get();
Object ctgrR = t.get2();
IgniteLogger log = IgnitionEx.localIgnite().log();
return ctgrR != null ? log.getLogger(ctgrR) : log;
} catch (IllegalStateException e) {
throw U.withCause(new InvalidObjectException(e.getMessage()), e);
} finally {
stash.remove();
}
}
use of java.io.InvalidObjectException in project ignite by apache.
the class SnapshotMetadata method readObject.
/**
* Reconstitute the <tt>HashMap</tt> instance of partitions and cache groups from a stream.
*/
private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {
// Read in any hidden serialization.
s.defaultReadObject();
// Read size and verify non-negative.
int size = s.readInt();
if (size < 0)
throw new InvalidObjectException("Illegal size: " + size);
locParts = U.newHashMap(size);
// Read in all elements in the proper order.
for (int i = 0; i < size; i++) {
int grpId = s.readInt();
int total = s.readInt();
if (total < 0)
throw new InvalidObjectException("Illegal size: " + total);
Set<Integer> parts = U.newHashSet(total);
for (int k = 0; k < total; k++) parts.add(s.readInt());
locParts.put(grpId, parts);
}
}
use of java.io.InvalidObjectException in project ignite by apache.
the class SensitiveInfoTestLoggerProxy method readResolve.
/**
* Reconstructs object on unmarshalling.
*
* @return Reconstructed object.
* @throws ObjectStreamException Thrown in case of unmarshalling error.
*/
protected Object readResolve() throws ObjectStreamException {
try {
IgniteBiTuple<String, Object> t = stash.get();
Object ctgrR = t.get2();
IgniteLogger log = IgnitionEx.localIgnite().log();
return ctgrR != null ? log.getLogger(ctgrR) : log;
} catch (IllegalStateException e) {
throw U.withCause(new InvalidObjectException(e.getMessage()), e);
} finally {
stash.remove();
}
}
use of java.io.InvalidObjectException in project j2objc by google.
the class TimeZoneFormat method readObject.
/**
* @param ois the object input stream
* @throws ClassNotFoundException
* @throws IOException
*/
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
ObjectInputStream.GetField fields = ois.readFields();
_locale = (ULocale) fields.get("_locale", null);
if (_locale == null) {
throw new InvalidObjectException("Missing field: locale");
}
_tznames = (TimeZoneNames) fields.get("_tznames", null);
if (_tznames == null) {
throw new InvalidObjectException("Missing field: tznames");
}
_gmtPattern = (String) fields.get("_gmtPattern", null);
if (_gmtPattern == null) {
throw new InvalidObjectException("Missing field: gmtPattern");
}
String[] tmpGmtOffsetPatterns = (String[]) fields.get("_gmtOffsetPatterns", null);
if (tmpGmtOffsetPatterns == null) {
throw new InvalidObjectException("Missing field: gmtOffsetPatterns");
} else if (tmpGmtOffsetPatterns.length < 4) {
throw new InvalidObjectException("Incompatible field: gmtOffsetPatterns");
}
_gmtOffsetPatterns = new String[6];
if (tmpGmtOffsetPatterns.length == 4) {
for (int i = 0; i < 4; i++) {
_gmtOffsetPatterns[i] = tmpGmtOffsetPatterns[i];
}
_gmtOffsetPatterns[GMTOffsetPatternType.POSITIVE_H.ordinal()] = truncateOffsetPattern(_gmtOffsetPatterns[GMTOffsetPatternType.POSITIVE_HM.ordinal()]);
_gmtOffsetPatterns[GMTOffsetPatternType.NEGATIVE_H.ordinal()] = truncateOffsetPattern(_gmtOffsetPatterns[GMTOffsetPatternType.NEGATIVE_HM.ordinal()]);
} else {
_gmtOffsetPatterns = tmpGmtOffsetPatterns;
}
_gmtOffsetDigits = (String[]) fields.get("_gmtOffsetDigits", null);
if (_gmtOffsetDigits == null) {
throw new InvalidObjectException("Missing field: gmtOffsetDigits");
} else if (_gmtOffsetDigits.length != 10) {
throw new InvalidObjectException("Incompatible field: gmtOffsetDigits");
}
_gmtZeroFormat = (String) fields.get("_gmtZeroFormat", null);
if (_gmtZeroFormat == null) {
throw new InvalidObjectException("Missing field: gmtZeroFormat");
}
_parseAllStyles = fields.get("_parseAllStyles", false);
if (fields.defaulted("_parseAllStyles")) {
throw new InvalidObjectException("Missing field: parseAllStyles");
}
// instance.
if (_tznames instanceof TimeZoneNamesImpl) {
_tznames = TimeZoneNames.getInstance(_locale);
// will be created by _locale later when necessary
_gnames = null;
} else {
// Custom TimeZoneNames implementation is used. We need to create
// a new instance of TimeZoneGenericNames here.
_gnames = new TimeZoneGenericNames(_locale, _tznames);
}
// Transient fields requiring initialization
initGMTPattern(_gmtPattern);
initGMTOffsetPatterns(_gmtOffsetPatterns);
}
Aggregations