private static int readBEInt()

in encryption/src/main/java/org/apache/solr/encryption/EncryptionTransactionLog.java [153:173]


  private static int readBEInt(FileChannel channel, long position, boolean requireAllBytes) throws IOException {
    ByteBuffer readBuffer = ByteBuffer.allocate(4);
    // Read 4 bytes.
    int bytesRead = channel.read(readBuffer, position);
    if (bytesRead < 4) {
      if (requireAllBytes) {
        throw new EOFException(
            bytesRead == -1 || bytesRead == 0
                ? "Header is empty; no data read."
                : "Incomplete header; expected 4 bytes, but only read " + bytesRead + " bytes.");
      } else {
        // If not requiring all bytes, just return 0.
        return 0;
      }
    }
    // Convert the 4 bytes to an integer in big-endian order
    return ((readBuffer.get(0) & 0xFF) << 24)
      | ((readBuffer.get(1) & 0xFF) << 16)
      | ((readBuffer.get(2) & 0xFF) << 8)
      | (readBuffer.get(3) & 0xFF);
  }