if(no connection) { //check connection throw new ConnectionException ("No connection!"); } else { ... }
@Override public void closeConnection() throws ConnectionException { if (client != null) { try { client.close(); } catch (IOException e) { throw new ConnectionException(e.getMessage(), e); } } }
/** * Remove (delete) the checkout directory. * * @throws ConnectionException if unable to clean up the checkout directory. */ private void removeCheckoutDirectory() throws ConnectionException { if (checkoutDirectory == null) { return; // Silently return. } try { FileUtils.deleteDirectory(checkoutDirectory); } catch (IOException e) { throw new ConnectionException("Unable to cleanup checkout directory", e); } }
private void removeCheckoutDirectory() throws ConnectionException { if ( checkoutDirectory == null ) { return; // Silently return. } try { deleteCheckoutDirectory(); } catch ( IOException e ) { throw new ConnectionException( "Unable to cleanup checkout directory", e ); } }
/** * Closes the connection * * @throws ConnectionException */ public void closeConnection() throws ConnectionException { try { if ( webdavResource != null ) { webdavResource.close(); } } catch ( IOException ioe ) { throw new ConnectionException( "Connection Exception: " + ioe.getMessage(), ioe ); } finally { webdavResource = null; } }
@Override public void openConnection() throws ConnectionException, AuthenticationException { try { doOpenConnection(); } catch (SVNCancelException e) { if(getDotJavaNetFile().exists()) throw new ConnectionException("Unable to connect to "+getSubversionURL(),e); else throw new ConnectionException("Unable to connect to "+getSubversionURL()+" You need to create "+getDotJavaNetFile()+" See https://javanettasks.dev.java.net/nonav/maven/config.html",e); } catch (SVNException e) { throw new ConnectionException("Unable to connect to "+getSubversionURL(),e); } }
throw new ConnectionException(); if (inStream == null) { inStream = this.socket.getInputStream();
public void openConnection() throws ConnectionException, AuthenticationException { try { doOpenConnection(); } catch (SVNException e) { throw new ConnectionException("Unable to connect to "+getSubversionURL(),e); } }
public static <T> List<T> queryObjectListSQL(String poolName, String sql, Class<T> type, Object[] params) { List<T> returnList = null; Connection con = null; try { con = DB_CONNECTION_MANAGER.getConnection(poolName); if (con == null) { throw new ConnectionException(poolName); } con.setAutoCommit(false); BeanListHandler<T> resultSetHandler = new BeanListHandler<T>(type); returnList = new QueryRunner().query(con, sql, resultSetHandler, params); con.commit(); } catch (Exception e) { logger.error(QUERY_EXCEPTION_MESSAGE, e); try { con.rollback(); } catch (SQLException e2) { logger.error(ROLLBACK_EXCEPTION_MESSAGE, e2); } } finally { DB_CONNECTION_MANAGER.freeConnection(poolName, con); } return returnList; }
@Override public void closeConnection() throws ConnectionException { if ( ftp != null && ftp.isConnected() ) { try { // This is a NPE rethink shutting down the streams ftp.disconnect(); } catch ( IOException e ) { throw new ConnectionException( "Failed to close connection to FTP repository", e ); } } }
@Override public void closeConnection() throws ConnectionException { if ( ftp != null && ftp.isConnected() ) { try { // This is a NPE rethink shutting down the streams ftp.disconnect(); } catch ( IOException e ) { throw new ConnectionException( "Failed to close connection to FTP repository", e ); } } }
protected void openConnectionInternal() throws ConnectionException { if ( getRepository() == null ) { throw new ConnectionException( "Unable to operate with a null repository." ); } if ( getRepository().getBasedir() == null ) { // This condition is possible when using wagon-file under integration testing conditions. fireSessionDebug( "Using a null basedir." ); return; } // Check the File repository exists File basedir = new File( getRepository().getBasedir() ); if ( !basedir.exists() ) { if ( !basedir.mkdirs() ) { throw new ConnectionException( "Repository path " + basedir + " does not exist," + " and cannot be created." ); } } if ( !basedir.canRead() ) { throw new ConnectionException( "Repository path " + basedir + " cannot be read" ); } }
/** * {@inheritDoc} */ public void closeConnection() throws ConnectionException { log.debug("Invoked closeConnection()"); try { git.pushAll(skipEmptyCommit); if (safeCheckout) FileUtils.cleanDirectory(git.workDir); } catch (Exception e) { throw new ConnectionException("Unable to push git repostory: " + e.getMessage(), e); } } }
protected void openConnectionInternal() throws ConnectionException { if ( getRepository() == null ) { throw new ConnectionException( "Unable to operate with a null repository." ); } if ( getRepository().getBasedir() == null ) { // This condition is possible when using wagon-file under integration testing conditions. fireSessionDebug( "Using a null basedir." ); return; } // Check the File repository exists File basedir = new File( getRepository().getBasedir() ); if ( !basedir.exists() ) { if ( !basedir.mkdirs() ) { throw new ConnectionException( "Repository path " + basedir + " does not exist," + " and cannot be created." ); } } if ( !basedir.canRead() ) { throw new ConnectionException( "Repository path " + basedir + " cannot be read" ); } }
throw new ConnectionException("Unable to create working directory"); git.pullAll(); } catch (Exception e) { throw new ConnectionException("Unable to pull git repository: " + e.getMessage(), e);
public final void disconnect() throws ConnectionException { sessionListeners.fireSessionDisconnecting(); try { disconnectFromRepository(); } catch (ConnectionException e) { sessionListeners.fireSessionConnectionRefused(); throw e; } catch (Exception e) { sessionListeners.fireSessionConnectionRefused(); throw new ConnectionException("Could not disconnect from repository", e); } sessionListeners.fireSessionLoggedOff(); sessionListeners.fireSessionDisconnected(); }
protected void closeConnection() throws ConnectionException { try { // beware that Maven often calls this method without first opening the connection // commit if(editor!=null) { try { editor.closeDir(); editor.closeEdit(); } catch (EmptyStackException e) { e.printStackTrace(); // debug probe } editor = null; } if(queryRepo !=null) queryRepo.closeSession(); queryRepo = null; if(commitRepo !=null) commitRepo.closeSession(); commitRepo = null; } catch (SVNException e) { throw new ConnectionException("Failed to close svn connection",e); } }
protected void doConnect(final Repository source, final AuthenticationInfo authenticationInfo, final ProxyInfo proxyInfo) throws ConnectionException, AuthenticationException { repository = source; log.debug("Connecting to " + repository.getUrl()); sessionListeners.fireSessionOpening(); try { connectToRepository(source, authenticationInfo, proxyInfo); } catch (ConnectionException e) { sessionListeners.fireSessionConnectionRefused(); throw e; } catch (AuthenticationException e) { sessionListeners.fireSessionConnectionRefused(); throw e; } catch (Exception e) { sessionListeners.fireSessionConnectionRefused(); throw new ConnectionException("Could not connect to repository", e); } sessionListeners.fireSessionLoggedIn(); sessionListeners.fireSessionOpened(); }
@Test public void testException() throws Exception { CompletableFuture<String> f1 = new CompletableFuture<>(); CompletableFuture<String> f2 = new CompletableFuture<>(); CompletableFuture<String> f3 = new CompletableFuture<>(); QuorumFuturesFactory.CompositeFuture<String> result = QuorumFuturesFactory.getQuorumFuture(String::compareTo, f1, f2, f3); f1.completeExceptionally(new ConnectionException("")); f3.complete(""); try { Object value = result.get(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis(), TimeUnit.MILLISECONDS); fail(); } catch (TimeoutException e) { // expected behaviour } f2.completeExceptionally(new IllegalArgumentException()); try { Object value = result.get(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis(), TimeUnit.MILLISECONDS); fail(); } catch (ExecutionException e) { // expected behaviour } assertTrue(result.isDone()); Set<Class> set = new LinkedHashSet<>(); for (Throwable t: result.getThrowables()) { set.add(t.getClass()); } assertTrue(set.contains(ConnectionException.class)); assertTrue(set.contains(IllegalArgumentException.class)); }
+ consoleOutput ); case 2: throw new ConnectionException( "Process exit status was: " + status + "Process output:\n" + consoleOutput ); case 3: