java.rmi.ServerException Java Examples

The following examples show how to use java.rmi.ServerException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Util.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
 
Example #2
Source File: Util.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
 
Example #3
Source File: Util.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
 
Example #4
Source File: Util.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
 
Example #5
Source File: Util.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
 
Example #6
Source File: Util.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
 
Example #7
Source File: Util.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
 
Example #8
Source File: Util.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
 
Example #9
Source File: Util.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
 
Example #10
Source File: UserController.java    From hermes with Apache License 2.0 6 votes vote down vote up
/**
 * 发送重置密码的邮件
 * 
 * @param email
 * @return
 * @throws Exception
 */
@RequestMapping("sendResetPwdEmail")
public String sendResetPwdEmail(String email, String token, Model model, HttpServletRequest request) throws Exception {
	try {
		if (Strings.empty(token)) {
			throw new ServerException("发送重置密码的邮件: 令牌不能为空");
		}
		if (!MailUtuils.isValidMail(email)) {
			throw new Exception("无效的邮件地址");
		}
		String generateMail = ModelLoader.process("mail_pwdForget.ftl", userService.getResetPwdEmailModel(email, request));
		emailService.sendEmail(email, "密码重置", generateMail);
	} catch (Exception e) {
		String commonMessage = "激活邮件发送失败,请重新发送!";
		Logger.error(commonMessage, e);
		model.addAttribute("errMsg", commonMessage);
	}
	model.addAttribute("email", email);
	return "user/retrievePwdStep2";
}
 
Example #11
Source File: ResponseResultProcess.java    From we-cmdb with Apache License 2.0 6 votes vote down vote up
@ResponseBody
@ExceptionHandler(Exception.class)
public ResponseDto<?> handleException(Exception ex) {
    logger.warn("Get exception:", ex);
    if (ex instanceof InvalidArgumentException) {
        InvalidArgumentException invalidArgExp = (InvalidArgumentException) ex;
        return new ResponseDto<Object>(ResponseDto.STATUS_ERROR_INVALID_ARGUMENT, invalidArgExp.getCauseData(), ex.getMessage());
    } else if (ex instanceof MethodArgumentNotValidException) {
        FieldError fieldError = ((MethodArgumentNotValidException) ex).getBindingResult().getFieldError();
        return new ResponseDto<String>(ResponseDto.STATUS_ERROR_INVALID_ARGUMENT, null, String.format("Please input valid field value.(%s:%s)", fieldError.getField(), fieldError.getRejectedValue()));
    } else if (ex instanceof HttpMessageNotReadableException) {
        return new ResponseDto<String>(ResponseDto.STATUS_ERROR_INVALID_MESSAGE, null, ex.getMessage());
    } else if (ex instanceof ServerException) {
        return new ResponseDto(ResponseDto.STATUS_ERROR, null, ex.getMessage());
    } else if (ex instanceof BatchChangeException) {
        return processBatchChangeException(ex);
    }
    return new ResponseDto(ResponseDto.STATUS_ERROR, null, ex.getMessage());
}
 
Example #12
Source File: Util.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
 
Example #13
Source File: CreationNotificationSender.java    From codenvy with Eclipse Public License 1.0 5 votes vote down vote up
private String doProcessTemplate(Template template) throws ServerException {
  try {
    return templateProcessor.process(template);
  } catch (TemplateException e) {
    throw new ServerException(e.getMessage(), e);
  }
}
 
Example #14
Source File: CreationNotificationSender.java    From codenvy with Eclipse Public License 1.0 5 votes vote down vote up
public void sendNotification(String userName, String userEmail, boolean withPassword)
    throws IOException, ApiException {
  final URL urlEndpoint = new URL(apiEndpoint);
  final String masterEndpoint = urlEndpoint.getProtocol() + "://" + urlEndpoint.getHost();
  final Template template =
      withPassword
          ? templateWithPassword(masterEndpoint, userEmail, userName)
          : templateWithoutPassword(masterEndpoint, userName);
  final EmailBean emailBean =
      new EmailBean()
          .withBody(doProcessTemplate(template))
          .withFrom(mailFrom)
          .withTo(userEmail)
          .withReplyTo(null)
          .withMimeType(TEXT_HTML);
  if (withPassword) {
    emailBean.setSubject(accountCreatedWithPasswordMailSubject);
  } else {
    emailBean.setSubject(accountCreatedWithoutPasswordMailSubject);
  }

  try {
    mailSender.sendMail(resourceResolver.resolve(emailBean));
  } catch (SendMailException e) {
    throw new ServerException(e.getMessage(), e);
  }
}
 
Example #15
Source File: FaultBeanGenerator.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Set<Class<?>> getExceptionClasses(final Method method) {
    Set<Class<?>> exps = new HashSet<>();
    final Class<?>[] exceptionClasses = method.getExceptionTypes();
    for (int i = 0; i < exceptionClasses.length; i++) {
        boolean exclude = false;
        Class<?> exClazz = exceptionClasses[i];

        if (exClazz.equals(Exception.class)
            || Fault.class.isAssignableFrom(exClazz)
            || exClazz.equals(RuntimeException.class)
            || exClazz.equals(Throwable.class)
            || exClazz.equals(RemoteException.class)
            || exClazz.equals(ServerException.class)) {
            continue;
        }

        Method[] expMethods = exClazz.getMethods();
        for (Method expMethod : expMethods) {
            if ("getFaultInfo".equals(expMethod.getName())) {
                exclude = true;
                break;
            }
        }
        if (exclude) {
            continue;
        }
        exps.add(exClazz);
    }
    return exps;
}
 
Example #16
Source File: MigrationServiceImpl.java    From x-pipe with Apache License 2.0 5 votes vote down vote up
@PostConstruct
private void postConstruct() throws ServerException {
    try {
        migrationShardTblDao = ContainerLoader.getDefaultContainer().lookup(MigrationShardTblDao.class);
    } catch (ComponentLookupException e) {
        throw new ServerException("Cannot construct dao.");
    }
}
 
Example #17
Source File: ThriftExceptionUtil.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static SQLException newSQLException(GFXDException gfxde) {
  GFXDExceptionData payload = gfxde.getExceptionData();
  SQLException sqle = newSQLException(payload, gfxde.getCause(),
      gfxde.getServerInfo());
  // since GFXDException is always a wrapper, no need to record the stack
  sqle.setStackTrace(gfxde.getStackTrace());
  // build next exceptions
  List<GFXDExceptionData> nextList = gfxde.getNextExceptions();
  SQLException current = sqle, next;
  if (nextList != null) {
    for (GFXDExceptionData nextData : nextList) {
      // check for server stack indicator
      if (SQLState.GFXD_SERVER_STACK_INDICATOR.equals(
          nextData.getSqlState())) {
        Throwable cause = sqle;
        while (cause.getCause() != null) {
          cause = cause.getCause();
        }
        cause.initCause(new ServerException(nextData.getReason()));
      }
      else {
        next = newSQLException(nextData, null, null);
        current.setNextException(next);
        current = next;
      }
    }
  }
  return sqle;
}
 
Example #18
Source File: PRClientServerRegionFunctionExecutionDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void executeFunction() throws ServerException,
    InterruptedException {

  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final HashSet testKeysSet = new HashSet();
  for (int i = (totalNumBuckets.intValue() * 10); i > 0; i--) {
    testKeysSet.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  Function function = new TestFunction(true,TEST_FUNCTION2);
  FunctionService.registerFunction(function);
  Execution dataSet = FunctionService.onRegion(region);
  try {
    ResultCollector rc1 = dataSet.withFilter(testKeysSet).withArgs(Boolean.TRUE).execute(
        function.getId());
    List l = ((List)rc1.getResult());
    getLogWriter().info("Result size : " + l.size());
    assertEquals(3, l.size());

    for (Iterator i = l.iterator(); i.hasNext();) {
      assertEquals(Boolean.TRUE, i.next());
    }
  }
  catch (Exception e) {
    getLogWriter().info("Got an exception : " + e.getMessage());
    assertTrue(e instanceof EOFException || e instanceof SocketException
        || e instanceof SocketTimeoutException
        || e instanceof ServerException || e instanceof IOException
        || e instanceof CacheClosedException);
  }
}
 
Example #19
Source File: PRClientServerRegionFunctionExecutionDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void executeFunction() throws ServerException,
    InterruptedException {

  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final HashSet testKeysSet = new HashSet();
  for (int i = (totalNumBuckets.intValue() * 10); i > 0; i--) {
    testKeysSet.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  Function function = new TestFunction(true,TEST_FUNCTION2);
  FunctionService.registerFunction(function);
  Execution dataSet = FunctionService.onRegion(region);
  try {
    ResultCollector rc1 = dataSet.withFilter(testKeysSet).withArgs(Boolean.TRUE).execute(
        function.getId());
    List l = ((List)rc1.getResult());
    getLogWriter().info("Result size : " + l.size());
    assertEquals(3, l.size());

    for (Iterator i = l.iterator(); i.hasNext();) {
      assertEquals(Boolean.TRUE, i.next());
    }
  }
  catch (Exception e) {
    getLogWriter().info("Got an exception : " + e.getMessage());
    assertTrue(e instanceof EOFException || e instanceof SocketException
        || e instanceof SocketTimeoutException
        || e instanceof ServerException || e instanceof IOException
        || e instanceof CacheClosedException);
  }
}
 
Example #20
Source File: ThriftExceptionUtil.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static SQLException newSQLException(GFXDException gfxde) {
  GFXDExceptionData payload = gfxde.getExceptionData();
  SQLException sqle = newSQLException(payload, gfxde.getCause(),
      gfxde.getServerInfo());
  // since GFXDException is always a wrapper, no need to record the stack
  sqle.setStackTrace(gfxde.getStackTrace());
  // build next exceptions
  List<GFXDExceptionData> nextList = gfxde.getNextExceptions();
  SQLException current = sqle, next;
  if (nextList != null) {
    for (GFXDExceptionData nextData : nextList) {
      // check for server stack indicator
      if (SQLState.GFXD_SERVER_STACK_INDICATOR.equals(
          nextData.getSqlState())) {
        Throwable cause = sqle;
        while (cause.getCause() != null) {
          cause = cause.getCause();
        }
        cause.initCause(new ServerException(nextData.getReason()));
      }
      else {
        next = newSQLException(nextData, null, null);
        current.setNextException(next);
        current = next;
      }
    }
  }
  return sqle;
}
 
Example #21
Source File: RMIDeserAttack.java    From BaRMIe with MIT License 5 votes vote down vote up
/*******************
 * Helper method which checks exceptions triggered by a deserialization
 * attacks and attempts to provide additional output to guide the user.
 * 
 * If a ServerException was caused by a ClassNotFoundException then we can
 * safely assume that the chosen gadget chain is not available on the
 * server.
 * 
 * If a ServerError was caused by an IOException which has "Cannot run
 * program" in the message then we can safely assume that the chosen gadget
 * chain is present, but the command wasn't available.
 * 
 * @param ex 
 ******************/
protected final void checkDeserException(Throwable t) {
	boolean responded = false;
	
	//Check for server-side ClassNotFoundException, indicating that the payload is no use
	if(t instanceof ServerException) {
		while(t.getCause() != null) {
			t = t.getCause();
			if(t instanceof ClassNotFoundException) {
				System.out.println("\n[-] The chosen deserialization payload is not available at the server side.");
				responded = true;
				break;
			}
		}
	}
	
	//Check for server-side IOException saying that the program could not be run, indicating a successful attack but unavailable target program
	if(t instanceof ServerError) {
		while(t.getCause() != null) {
			t = t.getCause();
			if(t instanceof IOException && t.getMessage().contains("Cannot run program")) {
				System.out.println("\n[+] The attack was successful, however the chosen command was not available.");
				responded = true;
				break;
			}
		}
	}
	
	//Print generic response if we can't work anything out from the exception
	if(responded == false) {
		System.out.println("\n[~] Attack completed but success could not be verified.");
	}
}
 
Example #22
Source File: IllegalRegistryBind.java    From BaRMIe with MIT License 5 votes vote down vote up
/*******************
 * Check if the given endpoint can be attacked.
 * 
 * This check is performed by executing a dummy attack against the
 * endpoint and observing the resulting exception.
 * 
 * @param ep An enumerated RMI endpoint.
 * @return True if we can attack it.
 ******************/
public boolean canAttackEndpoint(RMIEndpoint ep) {
	RMIBindExploitProxy proxy = null;
	Registry reg;
	
	//Execute a dummy attack
	try {
		//Start a bind exploit proxy
		proxy = new RMIBindExploitProxy(InetAddress.getByName(ep.getEndpoint().getHost()), ep.getEndpoint().getPort(), this._options, this._dummyPayload);
		proxy.startProxy();
		
		//Get a proxied RMI registry reference
		reg = LocateRegistry.getRegistry(proxy.getServerListenAddress().getHostAddress(), proxy.getServerListenPort());
		
		//Bind a dummy object in an attempt to trigger the vulnerability
		reg.bind(this.generateRandomString(), new BaRMIeBindExploit());
	} catch(BaRMIeException | UnknownHostException | RemoteException | AlreadyBoundException ex) {
		//An up to date RMI registry will, by default, reject the dummy object
		if(ex instanceof ServerException && ex.getCause() != null && ex.getCause() instanceof UnmarshalException && ex.getCause().getCause() != null && ex.getCause().getCause() instanceof InvalidClassException) {
			//Check for "filter status: REJECTED"
			if(ex.getCause().getCause().toString().contains("filter status: REJECTED")) {
				//Test payload was filtered, likely this attack isn't possible
				return false;
			}
		}
	} finally {
		//Stop the proxy
		if(proxy != null) {
			proxy.stopProxy(true);
		}
	}
	
	//In all other cases we should be able to attack the registry
	return true;
}
 
Example #23
Source File: RMIConnector.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example #24
Source File: RMIConnector.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example #25
Source File: RMIConnector.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example #26
Source File: RMIConnector.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example #27
Source File: RMIConnector.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example #28
Source File: RMIConnector.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example #29
Source File: GroupShopService.java    From unimall with Apache License 2.0 4 votes vote down vote up
@HttpMethod(description = "获取团购列表")
public Page<GroupShopDTO> getGroupShopPage(
        @HttpParam(name = "page", type = HttpParamType.COMMON, description = "页码", valueDef = "1") Integer pageNo,
        @HttpParam(name = "pageSize", type = HttpParamType.COMMON, description = "页码长度", valueDef = "10") Integer pageSize) throws ServerException;
 
Example #30
Source File: GroupShopServiceImpl.java    From unimall with Apache License 2.0 4 votes vote down vote up
@Override
public Page<GroupShopDTO> getGroupShopPage(Integer pageNo, Integer pageSize) throws ServerException {
    Integer count = groupShopMapper.selectCount(null);
    List<GroupShopDTO> groupShopPage = groupShopMapper.getGroupShopPage((pageNo - 1) * pageSize, pageSize);
    return new Page<>(groupShopPage, pageNo, pageSize, count);
}