Example usage for java.io EOFException getMessage

List of usage examples for java.io EOFException getMessage

Introduction

In this page you can find the example usage for java.io EOFException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.pepstock.jem.ant.tasks.utilities.SortTask.java

/**
 * /*from   w  ww.  j ava2s  .c o  m*/
 * @throws IOException
 */
private void reload() throws IOException {
    try {
        if ((this.cache = bufferReader.readLine()) == null) {
            empty = true;
            cache = null;
        } else {
            empty = false;
        }
    } catch (EOFException oef) {
        // ignore
        LogAppl.getInstance().ignore(oef.getMessage(), oef);

        empty = true;
        cache = null;
    }
}

From source file:org.hyperic.hq.agent.client.AgentConnection.java

/**
 * Get the result of command execution from the remote command handler.
 *
 * @param inStreamPair The pair which was returned from the associated
 *                     sendCommandHeaders invocation.
 *
 * @return an AgentRemoteValue object, as returned from the Agent.
 *
 * @throws AgentRemoteException indicating an error invoking the method.
 * @throws AgentConnectionException indicating a failure to communicate
 *                                  with the agent.
 *///from w  w  w .java  2 s .  co  m

public AgentRemoteValue getCommandResult(AgentStreamPair inStreamPair)
        throws AgentRemoteException, AgentConnectionException {
    SocketStreamPair streamPair = (SocketStreamPair) inStreamPair;
    // Get the response
    try {
        DataInputStream inputStream;
        int isException;

        inputStream = new DataInputStream(streamPair.getInputStream());
        isException = inputStream.readInt();
        if (isException == 1) {
            String exceptionMsg = inputStream.readUTF();

            throw new AgentRemoteException(exceptionMsg);
        } else {
            AgentRemoteValue result;

            result = AgentRemoteValue.fromStream(inputStream);
            return result;
        }
    } catch (EOFException exc) {
        throw new AgentConnectionException("EOF received from Agent");
    } catch (IOException exc) {
        throw new AgentConnectionException("Error reading result: " + exc.getMessage(), exc);
    } finally {
        close(streamPair);
    }
}

From source file:org.apache.tajo.storage.v2.ScheduledInputStream.java

public boolean readNext(int length, boolean ignoreEOS) throws IOException {
    synchronized (dataQueue) {
        if (closed.get() || (!ignoreEOS && endOfStream)) {
            return false;
        }/* ww w  .  jav a  2 s  .c  om*/
        int bufLength = ignoreEOS ? length : (int) Math.min(length, endOffset - originStream.getPos());
        bufLength = (int) Math.min(bufLength, fileLen - originStream.getPos());
        if (bufLength == 0) {
            return false;
        }
        byte[] buf = new byte[bufLength];

        try {
            originStream.readFully(buf);
        } catch (EOFException e) {
            LOG.error(e.getMessage(), e);
            throw e;
        } catch (Exception e) {
            throw new IOException(e.getMessage(), e);
        }

        if (originStream.getPos() == fileLen) {
            LOG.info("EOF:" + toString());
            eof = true;
        }
        if (!ignoreEOS && originStream.getPos() >= endOffset) {
            LOG.info("EndOfStream:" + toString());
            endOfStream = true;
        }

        if (currentScanData == null) {
            currentScanData = new ScanData(buf, bufLength);
            currentScanIndex = 0;
        } else {
            dataQueue.offer(new ScanData(buf, bufLength));
        }

        avaliableSize.addAndGet(bufLength);

        if (LOG.isDebugEnabled()) {
            LOG.debug("Add DataQueue: queue=" + dataQueue.size() + ", avaliable Size=" + avaliableSize.get()
                    + ", pos=" + getPos() + ", originPos=" + originStream.getPos() + ",endOfStream="
                    + endOfStream + ", bufLength=" + bufLength + ",ignoreEOS=" + ignoreEOS);
        }

        totalReadBytesFromDisk.addAndGet(bufLength);
        dataQueue.notifyAll();
    }
    return !eof;
}

From source file:org.squidy.manager.commander.Incoming.java

@Override
public void run() {

    while (running) {
        try {/*from  w  ww . j a  va 2  s  . c  om*/
            Object o = inputStream.readObject();

            if (LOG.isDebugEnabled()) {
                LOG.debug("Received object " + o + " of class " + o.getClass());
            }

            if (o instanceof ICommand) {
                //               ICommand cmd = ((ICommand) o).execute(context);
                ((ICommand) o).execute(context);

                //               if (connectionPeer != null) {
                //                  connectionPeer.send(cmd);
                //               }
            }
        } catch (EOFException e) {
            try {
                close();
            } catch (IOException e1) {
                if (LOG.isErrorEnabled()) {
                    LOG.error(e1.getMessage(), e1);
                }
            }
        } catch (SocketException e) {
            try {
                if (LOG.isInfoEnabled()) {
                    LOG.info("Closing incoming thread caused by: " + e.getMessage(), e);
                }
                close();
            } catch (IOException e1) {
                if (LOG.isInfoEnabled()) {
                    LOG.info("Closing incoming thread caused by: " + e.getMessage(), e);
                }
                if (LOG.isErrorEnabled()) {
                    LOG.error(e1.getMessage(), e1);
                }
            }
        } catch (IOException e) {
            if (LOG.isErrorEnabled()) {
                LOG.error(e.getMessage(), e);
            }
        } catch (ClassNotFoundException e) {
            if (LOG.isErrorEnabled()) {
                LOG.error(e.getMessage(), e);
            }
        }
    }
}

From source file:org.mule.util.journal.TransactionJournalFile.java

private void loadAllEntries() {
    if (!journalFile.exists()) {
        return;/*from ww w .  jav a2  s  . c  o m*/
    }
    DataInputStream dataInputStream = null;
    try {
        dataInputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(journalFile)));
        boolean logEntryCreationFailed = false;
        while (!logEntryCreationFailed) {
            try {
                K journalEntry = journalEntrySerializer.deserialize(dataInputStream);
                if (journalEntry != null) {
                    this.entries.put(journalEntry.getTxId(), journalEntry);
                } else {
                    logEntryCreationFailed = true;
                }
            } catch (EOFException e) {
                logger.debug("Expected exception since there are no more log entries", e);
                logEntryCreationFailed = true;
            } catch (Exception e) {
                logger.warn(
                        "Exception reading transaction content. This is normal if the mule server was shutdown due to a failure"
                                + e.getMessage());
                if (logger.isDebugEnabled()) {
                    logger.debug(e);
                }
                logEntryCreationFailed = true;
            }
        }
    } catch (FileNotFoundException e) {
        throw new RuntimeException(e);
    } finally {
        try {
            if (dataInputStream != null) {
                dataInputStream.close();
            }
        } catch (IOException e) {
            logger.error(e);
        }
    }
}

From source file:com.qwazr.utils.server.InFileSessionPersistenceManager.java

private PersistentSession readSession(File sessionFile) {
    try {/*from   www  .ja  va2s . c o m*/
        final FileInputStream fileInputStream = new FileInputStream(sessionFile);
        try {
            final ObjectInputStream in = new ObjectInputStream(fileInputStream);
            try {
                final Date expDate = new Date(in.readLong());
                final HashMap<String, Object> sessionData = new HashMap<>();
                try {
                    for (;;)
                        readSessionAttribute(in, sessionData);
                } catch (EOFException e) {
                    ;// Ok we reached the end of the file
                }
                return sessionData.isEmpty() ? null : new PersistentSession(expDate, sessionData);
            } finally {
                IOUtils.close(in);
            }
        } finally {
            IOUtils.close(fileInputStream);
        }
    } catch (IOException e) {
        if (logger.isWarnEnabled())
            logger.warn("Cannot load sessions from " + sessionFile + " " + e.getMessage(), e);
        return null;
    }
}

From source file:fabiogentile.powertutor.ui.UMLogger.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_PREFERENCES:
        startActivity(new Intent(this, EditPreferences.class));
        return true;
    case MENU_SAVE_LOG:
        new Thread() {
            public void start() {
                File writeFile = new File(Environment.getExternalStorageDirectory(),
                        "PowerTrace" + System.currentTimeMillis() + ".log");

                try {
                    InflaterInputStream logIn = new InflaterInputStream(openFileInput("PowerTrace.log"));
                    BufferedOutputStream logOut = new BufferedOutputStream(new FileOutputStream(writeFile));

                    byte[] buffer = new byte[20480];
                    for (int ln = logIn.read(buffer); ln != -1; ln = logIn.read(buffer)) {
                        logOut.write(buffer, 0, ln);
                    }// w  w w. j a  va  2s . c o m
                    logIn.close();
                    logOut.close();
                    Toast.makeText(UMLogger.this, "Wrote log to " + writeFile.getAbsolutePath(),
                            Toast.LENGTH_SHORT).show();
                    return;

                } catch (EOFException e) {
                    Toast.makeText(UMLogger.this, "Wrote log to " + writeFile.getAbsolutePath(),
                            Toast.LENGTH_SHORT).show();
                    return;
                } catch (IOException e) {
                    Log.e(TAG, "failed to save log: " + e.getMessage());
                }
                Toast.makeText(UMLogger.this, "Failed to write log to sdcard", Toast.LENGTH_SHORT).show();
            }
        }.start();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.maverick.ssl.SSLTransportImpl.java

void processMessages() throws SSLException, EOFException {

    int type = 0;
    byte[] fragment = null;
    try {//  w  w w.  j  av  a2s  .  c  o  m
        type = rawIn.read();
        int major = rawIn.read();
        int minor = rawIn.read();

        int length = rawIn.readShort();

        fragment = new byte[length];

        rawIn.readFully(fragment);

        readCipherSuite.decrypt(fragment, 0, fragment.length);

        if (readCipherSuite.getMACLength() > 0) {
            if (!readCipherSuite.verifyMAC(fragment, 0, fragment.length - readCipherSuite.getMACLength(), type,
                    incomingSequence, fragment, fragment.length - readCipherSuite.getMACLength(),
                    readCipherSuite.getMACLength())) {
                throw new SSLException(SSLException.PROTOCOL_VIOLATION,
                        Messages.getString("SSLTransport.invalidMAC")); //$NON-NLS-1$
            }

        }
    } catch (EOFException ex) {
        throw ex;
    } catch (InterruptedIOException ex) {
        throw new SSLException(SSLException.READ_TIMEOUT);
    } catch (IOException ex) {
        throw new SSLException(SSLException.UNEXPECTED_TERMINATION,
                ex.getMessage() == null ? ex.getClass().getName() : ex.getMessage());
    }

    incomingSequence++;

    // #ifdef DEBUG
    log.debug(MessageFormat.format(Messages.getString("SSLTransport.processingFragmentOfType"), //$NON-NLS-1$
            new Object[] { new Integer(type) }));
    // #endif

    switch (type) {
    case SSLHandshakeProtocol.HANDSHAKE_PROTOCOL_MSG:
        handshake.processMessage(fragment, 0, fragment.length - readCipherSuite.getMACLength());
        break;
    case CHANGE_CIPHER_SPEC_MSG:

        // #ifdef DEBUG

        log.debug(Messages.getString("SSLTransport.changingInputCipherSpec")); //$NON-NLS-1$
        // #endif

        readCipherSuite = handshake.getPendingCipherSuite();
        incomingSequence = 0;
        break;
    case ALERT_PROTOCOL:
        switch (fragment[0]) {
        case FATAL_ALERT:
            throw new SSLException(((int) (fragment[1] & 0xFF)));
        case WARNING_ALERT:
            switch (fragment[1]) {
            case SSLException.CLOSE_NOTIFY:

                // #ifdef DEBUG
                log.debug(Messages.getString("SSLTransport.remoteSideClosing")); //$NON-NLS-1$
                // #endif

                sendMessage(ALERT_PROTOCOL,
                        new byte[] { (byte) WARNING_ALERT, (byte) SSLException.CLOSE_NOTIFY });
                // close();
                // Let the InputStream know that we're at EOF
                throw new EOFException();

            default:

                // #ifdef DEBUG
                log.warn(SSLException.getDescription(fragment[1]));
                // #endif

                break;
            }

            break;
        default:

            // #ifdef DEBUG
            log.debug(MessageFormat.format(Messages.getString("SSLTransport.unexpectedAlert"), //$NON-NLS-1$
                    new Object[] { new Integer(fragment[0]), new Integer(fragment[1]) }));
            // #endif

            break;
        }
    case APPLICATION_DATA:
        sslIn.write(fragment, 0, fragment.length - readCipherSuite.getMACLength());
        break;
    default:
        throw new SSLException(SSLException.PROTOCOL_VIOLATION,
                Messages.getString("SSLTransport.unexpecedSSLProtocolType") + type); //$NON-NLS-1$

    }

}

From source file:org.skyscreamer.nevado.jms.message.NevadoBytesMessage.java

/**
 * Reads a <code>boolean</code> from the bytes message stream.
 *
 * @return the <code>boolean</code> value read
 * @throws JMSException                if the JMS provider fails to read the message due to some internal error.
 * @throws MessageEOFException         if unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException if the message is in write-only mode.
 *///  w w w.  java2s. c o  m
public boolean readBoolean() throws JMSException {
    initializeReading();
    try {
        return this.dataIn.readBoolean();
    } catch (EOFException eof) {
        JMSException jmsEx = new MessageEOFException(eof.getMessage());
        jmsEx.setLinkedException(eof);
        throw jmsEx;
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Format error occured" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoBytesMessage.java

/**
 * Reads a signed 8-bit value from the bytes message stream.
 *
 * @return the next byte from the bytes message stream as a signed 8-bit <code>byte</code>
 * @throws JMSException                if the JMS provider fails to read the message due to some internal error.
 * @throws MessageEOFException         if unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException if the message is in write-only mode.
 *///from w w  w  .ja  va 2s. co  m
public byte readByte() throws JMSException {
    initializeReading();
    try {
        return this.dataIn.readByte();
    } catch (EOFException eof) {
        JMSException jmsEx = new MessageEOFException(eof.getMessage());
        jmsEx.setLinkedException(eof);
        throw jmsEx;
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Format error occured" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}