Java Code Examples for java.rmi.ServerException

The following examples show how to use java.rmi.ServerException. These examples are extracted from open source projects. 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 Project: we-cmdb   Source File: ResponseResultProcess.java    License: 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 2
Source Project: jdk1.8-source-analysis   Source File: Util.java    License: 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 3
Source Project: TencentKona-8   Source File: Util.java    License: 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 Project: jdk8u60   Source File: Util.java    License: 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 Project: JDKSourceCode1.8   Source File: Util.java    License: 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 6
Source Project: openjdk-jdk8u   Source File: Util.java    License: 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 Project: openjdk-jdk8u-backup   Source File: Util.java    License: 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 Project: openjdk-jdk9   Source File: Util.java    License: 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 Project: hottub   Source File: Util.java    License: 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 Project: openjdk-8-source   Source File: Util.java    License: 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 11
Source Project: openjdk-8   Source File: Util.java    License: 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 12
Source Project: hermes   Source File: UserController.java    License: 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 13
Source Project: BaRMIe   Source File: IllegalRegistryBind.java    License: 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 14
Source Project: BaRMIe   Source File: RMIDeserAttack.java    License: 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 15
Source Project: gemfirexd-oss   Source File: ThriftExceptionUtil.java    License: 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 16
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 17
Source Project: x-pipe   Source File: MigrationServiceImpl.java    License: 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 18
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 19
private String doProcessTemplate(Template template) throws ServerException {
  try {
    return templateProcessor.process(template);
  } catch (TemplateException e) {
    throw new ServerException(e.getMessage(), e);
  }
}
 
Example 20
Source Project: gemfirexd-oss   Source File: ThriftExceptionUtil.java    License: 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
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 22
Source Project: cxf   Source File: FaultBeanGenerator.java    License: 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 23
Source Project: jdk1.8-source-analysis   Source File: RMIConnector.java    License: 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 24
Source Project: dragonwell8_jdk   Source File: RMIConnector.java    License: 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 25
Source Project: TencentKona-8   Source File: RMIConnector.java    License: 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 Project: unimall   Source File: GroupShopService.java    License: 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 27
Source Project: unimall   Source File: GroupShopServiceImpl.java    License: 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);
}
 
Example 28
Source Project: jdk8u60   Source File: RMIConnector.java    License: 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 Project: JDKSourceCode1.8   Source File: RMIConnector.java    License: MIT License 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 30
Source Project: openjdk-jdk8u   Source File: RMIConnector.java    License: 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;
}