/** * Returns {@link NamingException#getResolvedObj()} if the {@code cause} is a * {@code NamingException}. Returns <tt>null</tt> for any other type of {@code cause}. * * @return {@code NamingException#getResolvedObj()} if the {@code cause} is a * {@code NamingException}. */ protected Object getResolvedObj() { final Throwable thisCause = this.cause; if (thisCause != null && NamingException.class.isInstance(thisCause)) { return ((NamingException) thisCause).getResolvedObj(); } return null; }
private void handleResolveObj(NamingException exception) { Object resolvedObj = exception.getResolvedObj(); boolean serializable = resolvedObj instanceof Serializable; if (resolvedObj != null && !serializable) { exception.setResolvedObj(null); } }
@Test public void serializesWithSerializableNamingException() { GemFireSecurityException instance = new GemFireSecurityException(message, serializableNamingException); GemFireSecurityException cloned = (GemFireSecurityException) SerializationUtils.clone(instance); assertThat(cloned).hasMessage(message).hasCause(serializableNamingException); NamingException cause = (NamingException) cloned.getCause(); assertThat(cause).hasMessage(causeMessage); assertThat(cause.getResolvedObj()).isNotNull().isEqualTo(serializableResolvedObj); }
@Test public void serializesWithNonSerializableNamingException() { GemFireSecurityException instance = new GemFireSecurityException(message, nonSerializableNamingException); GemFireSecurityException cloned = (GemFireSecurityException) SerializationUtils.clone(instance); assertThat(cloned).hasMessage(message).hasCause(nonSerializableNamingException); NamingException cause = (NamingException) cloned.getCause(); assertThat(cause).hasMessage(causeMessage); assertThat(cause.getResolvedObj()).isNull(); }
private void handleResolveObj(NamingException exception) { Object resolvedObj = exception.getResolvedObj(); boolean serializable = resolvedObj instanceof Serializable; if (resolvedObj != null && !serializable) { exception.setResolvedObj(null); } }
/** * Convenience method to get the resolved object associated with this * exception, if the root cause was an instance of * {@link javax.naming.NamingException}. * * @return the object that was resolved so far if the root cause is an * instance of javax.naming.NamingException, or <code>null</code> * if the resolved object field has not been set */ public Object getResolvedObj() { if (getCause() instanceof javax.naming.NamingException) { return ((javax.naming.NamingException) getCause()).getResolvedObj(); } return null; }
/** * Convenience method to get the resolved object associated with this * exception, if the root cause was an instance of * {@link javax.naming.NamingException}. * * @return the object that was resolved so far if the root cause is an * instance of javax.naming.NamingException, or <code>null</code> * if the resolved object field has not been set */ public Object getResolvedObj() { if (getCause() instanceof javax.naming.NamingException) { return ((javax.naming.NamingException) getCause()).getResolvedObj(); } return null; }
/** * Convenience method to get the resolved object associated with this * exception, if the root cause was an instance of * {@link javax.naming.NamingException}. * * @return the object that was resolved so far if the root cause is an * instance of javax.naming.NamingException, or <code>null</code> * if the resolved object field has not been set */ public Object getResolvedObj() { if (getCause() instanceof javax.naming.NamingException) { return ((javax.naming.NamingException) getCause()).getResolvedObj(); } return null; }
/** * Convenience method to get the resolved object associated with this * exception, if the root cause was an instance of * {@link javax.naming.NamingException}. * * @return the object that was resolved so far if the root cause is an * instance of javax.naming.NamingException, or <code>null</code> * if the resolved object field has not been set */ public Object getResolvedObj() { if (getCause() instanceof javax.naming.NamingException) { return ((javax.naming.NamingException) getCause()).getResolvedObj(); } return null; }