Search Results

Search found 173 results on 7 pages for 'nio'.

Page 1/7 | 1 2 3 4 5 6 7  | Next Page >

  • Strange exception of Httpcore nio in java

    - by bruce dou
    Exception in thread "Thread-0" java.lang.NullPointerException at org.apache.http.impl.nio.reactor.AbstractIOReactor.closeActiveChannels(AbstractIOReactor.java:532) at org.apache.http.impl.nio.reactor.AbstractIOReactor.hardShutdown(AbstractIOReactor.java:564) at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.doShutdown(AbstractMultiworkerIOReactor.java:411) at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:340) at com.***.clawer.Clawer$1.run(Clawer.java:81) at java.lang.Thread.run(Unknown Source) Exception in thread "Thread-1" java.lang.IllegalStateException: I/O reactor has been shut down at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.connect(DefaultConnectingIOReactor.java:190) at com.***.clawer.Run.run(Run.java:29)

    Read the article

  • Java NIO Servlet to File

    - by Gandalf
    Is there a way (without buffering the whole Inputstream) to take the HttpServletRequest from a Java Servlet and write it out to a file using all NIO? Is it even worth trying? Will it be any faster reading from a normal java.io stream and writing to a java.nio Channel or do they both really need to be pure NIO to see a benefit? Thanks.

    Read the article

  • IOException during blocking network NIO in JDK 1.7

    - by Bass
    I'm just learning NIO, and here's the short example I've written to test how a blocking NIO can be interrupted: class TestBlockingNio { private static final boolean INTERRUPT_VIA_THREAD_INTERRUPT = true; /** * Prevent the socket from being GC'ed */ static Socket socket; private static SocketChannel connect(final int port) { while (true) { try { final SocketChannel channel = SocketChannel.open(new InetSocketAddress(port)); channel.configureBlocking(true); return channel; } catch (final IOException ioe) { try { Thread.sleep(1000); } catch (final InterruptedException ie) { } continue; } } } private static byte[] newBuffer(final int length) { final byte buffer[] = new byte[length]; for (int i = 0; i < length; i++) { buffer[i] = (byte) 'A'; } return buffer; } public static void main(final String args[]) throws IOException, InterruptedException { final int portNumber = 10000; new Thread("Reader") { public void run() { try { final ServerSocket serverSocket = new ServerSocket(portNumber); socket = serverSocket.accept(); /* * Fully ignore any input from the socket */ } catch (final IOException ioe) { ioe.printStackTrace(); } } }.start(); final SocketChannel channel = connect(portNumber); final Thread main = Thread.currentThread(); final Thread interruptor = new Thread("Inerruptor") { public void run() { System.out.println("Press Enter to interrupt I/O "); while (true) { try { System.in.read(); } catch (final IOException ioe) { ioe.printStackTrace(); } System.out.println("Interrupting..."); if (INTERRUPT_VIA_THREAD_INTERRUPT) { main.interrupt(); } else { try { channel.close(); } catch (final IOException ioe) { System.out.println(ioe.getMessage()); } } } } }; interruptor.setDaemon(true); interruptor.start(); final ByteBuffer buffer = ByteBuffer.allocate(32768); int i = 0; try { while (true) { buffer.clear(); buffer.put(newBuffer(buffer.capacity())); buffer.flip(); channel.write(buffer); System.out.print('X'); if (++i % 80 == 0) { System.out.println(); Thread.sleep(100); } } } catch (final ClosedByInterruptException cbie) { System.out.println("Closed via Thread.interrupt()"); } catch (final AsynchronousCloseException ace) { System.out.println("Closed via Channel.close()"); } } } In the above example, I'm writing to a SocketChannel, but noone is reading from the other side, so eventually the write operation hangs. This example works great when run by JDK-1.6, with the following output: Press Enter to interrupt I/O XXXX Interrupting... Closed via Thread.interrupt() — meaning that only 128k of data was written to the TCP socket's buffer. When run by JDK-1.7 (1.7.0_25-b15 and 1.7.0-u40-b37), however, the very same code bails out with an IOException: Press Enter to interrupt I/O XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXX Exception in thread "main" java.io.IOException: Broken pipe at sun.nio.ch.FileDispatcherImpl.write0(Native Method) at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) at sun.nio.ch.IOUtil.write(IOUtil.java:65) at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487) at com.example.TestBlockingNio.main(TestBlockingNio.java:109) Can anyone explain this different behaviour?

    Read the article

  • JavaOne 2012 - The Power of Java 7 NIO.2

    - by Sharon Zakhour
    At JavaOne 2012, Mohamed Taman of e-finance gave a presentation highlighting the power of NIO.2, the file I/O APIs introduced in JDK 7. He shared information on how to get the most out of NIO.2, gave tips on migrating your I/O code to NIO.2, and presented case studies. The File I/O (featuring NIO.2) lesson in the Java Tutorials has extensive coverage of NIO.2 and includes the following topics: Managing Metadata Walking the File Tree Finding Files, including information on using PatternMatcher and globs. Watching a Directory for Changes Legacy File I/O Code includes information on migrating your code. From the conference session page, you can watch the presentation or download the materials.

    Read the article

  • Jetty 7 NIO issue?

    - by Continuation
    I saw this test showing Jetty 7's performance drops drastically when switched from blocking IO to NIO (95% drop): http://wiki.apache.org/HttpComponents/HttpCoreBenchmark Is this a known issue? Have you experienced it first hand? Should I be avoiding NIO on Jetty?

    Read the article

  • Mixing NIO with IO

    - by Steffen Heil
    Hi Usually you have a single bound tcp port and several connections on these. At least there are usually more connections as bound ports. My case is different: I want to bind a lot of ports and usually have no (or at least very few) connections. So I want to use NIO to accept the incoming connections. However, I need to pass the accepted connections to the existing jsch ssh library. That requires IO sockets instead of NIO sockets, it spawns one (or two) thread(s) per connection. But that's fine for me. Now, I thought that the following lines would deliver the very same result: Socket a = serverSocketChannel.accept().socket(); Socket b = serverSocketChannel.socket().accep(); SocketChannel channel = serverSocketChannel.accpet(); channel.configureBlocking( true ); Socket c = channel.socket(); Socket d = serverSocket.accept(); However the getInputStream() and getOutputStream() functions of the returned sockets seem to work different. Only if the socket was accepted using the last call, jsch can work with it. In the first three cases, it fails (and I am sorry: I don't know why). So is there a way to convert such a socket? Regards, Steffen

    Read the article

  • Help with httpcore NIO exception

    - by bruce dou
    I/O error: I/O dispatch worker terminated abnormally Exception in thread "Thread-1" java.lang.IllegalStateException: I/O reactor has been shut down at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.connect(DefaultConnectingIOReactor.java:190)

    Read the article

  • How Can I create different selectors for accepting new connection in java NIO

    - by Deepak
    I want to write java tcp socket programming using java NIO. Its working fine. But I am using the same selector for accepting reading from and writing to the clients. How Can I create different selectors for accepting new connection in java NIO, reading and writing. Is there any online help. Actually when I am busy in reading or writing my selector uses more iterator. So If more number of clients are connected then performance of accepting new coneection became slow. But I donot want the accepting clients to be slow // Create a selector and register two socket channels Selector selector = null; try { // Create the selector selector = Selector.open(); // Create two non-blocking sockets. This method is implemented in // e173 Creating a Non-Blocking Socket. SocketChannel sChannel1 = createSocketChannel("hostname.com", 80); SocketChannel sChannel2 = createSocketChannel("hostname.com", 80); // Register the channel with selector, listening for all events sChannel1.register(selector, sChannel1.validOps()); sChannel2.register(selector, sChannel1.validOps()); } catch (IOException e) { } // Wait for events while (true) { try { // Wait for an event selector.select(); } catch (IOException e) { // Handle error with selector break; } // Get list of selection keys with pending events Iterator it = selector.selectedKeys().iterator(); // Process each key at a time while (it.hasNext()) { // Get the selection key SelectionKey selKey = (SelectionKey)it.next(); // Remove it from the list to indicate that it is being processed it.remove(); try { processSelectionKey(selKey); } catch (IOException e) { // Handle error with channel and unregister selKey.cancel(); } } } public void processSelectionKey(SelectionKey selKey) throws IOException { // Since the ready operations are cumulative, // need to check readiness for each operation if (selKey.isValid() && selKey.isConnectable()) { // Get channel with connection request SocketChannel sChannel = (SocketChannel)selKey.channel(); boolean success = sChannel.finishConnect(); if (!success) { // An error occurred; handle it // Unregister the channel with this selector selKey.cancel(); } } if (selKey.isValid() && selKey.isReadable()) { // Get channel with bytes to read SocketChannel sChannel = (SocketChannel)selKey.channel(); // See e174 Reading from a SocketChannel } if (selKey.isValid() && selKey.isWritable()) { // Get channel that's ready for more bytes SocketChannel sChannel = (SocketChannel)selKey.channel(); } } Thanks Deepak

    Read the article

  • Testing SocketChannel NIO

    - by hotzen
    Hello, I just wrote some NIO-code and wonder how to stress-test my implementation regarding SocketChannel.write(ByteBuffer) not able to write the whole byte-buffer SocketChannel.read(ByteBuffer) reading the data in chunks into ByteBuffer are there some simple linux-utilities like telnet to open a ServerSocket with some buffering-options?

    Read the article

  • Java programs using NIO framework

    - by peng
    Hello, everyone I am doing some research related to Java NIO. I need to find some representative applications that are based on this framework. Please feel free to suggest! The more, the merrier! Thanks

    Read the article

  • Apache MINA NIO connector help

    - by satya
    I'm new to using MINA. I've a program which uses MINA NIOconnector to connect to host. I'm able to send data and also receive. This is clear from log4j log which i'm attaching below. E:\>java TC4HostClient [12:21:46] NioProcessor-1 INFO [] [] [org.apache.mina.filter.logging.LoggingFil ter] - CREATED [12:21:46] NioProcessor-1 INFO [] [] [org.apache.mina.filter.logging.LoggingFil ter] - OPENED Opened CGS Sign On [12:21:46] NioProcessor-1 INFO [] [] [org.apache.mina.filter.logging.LoggingFil ter] - SENT: HeapBuffer[pos=0 lim=370 cap=512: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20...] [12:21:46] NioProcessor-1 INFO [] [] [org.apache.mina.filter.logging.LoggingFil ter] - SENT: HeapBuffer[pos=0 lim=0 cap=0: empty] Message Sent 00000333CST 1001010 00000308000003080010000 000009600000000FTS O00000146TC4DS 001WSJTC41 ---001NTMU9001-I --- -----000 0030000000012400000096500007013082015SATYA 500000 010165070000002200011 01800000000022000001241 172.16.25.122 02 [12:21:46] NioProcessor-1 INFO [] [] [org.apache.mina.filter.logging.LoggingFil ter] - RECEIVED: HeapBuffer[pos=0 lim=36 cap=2048: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20...] [12:21:46] NioProcessor-1 INFO [] [] [org.apache.mina.filter.logging.LoggingFil ter] - RECEIVED: HeapBuffer[pos=0 lim=505 cap=2048: 31 20 20 20 20 20 20 20 20 3 0 30 30 30 30 34 38...] After Writing [12:21:52] NioProcessor-1 INFO [] [] [org.apache.mina.filter.logging.LoggingFil ter] - CLOSED Though i see "RECEIVED" in log my handler messageReceived method is not being called. Can anyone please help me in this regard and tell me what i'm doing wrong import java.io.IOException; import java.net.InetSocketAddress; import java.nio.charset.Charset; import java.net.SocketAddress; import org.apache.mina.core.service.IoAcceptor; import org.apache.mina.core.session.IdleStatus; import org.apache.mina.filter.codec.ProtocolCodecFilter; import org.apache.mina.filter.codec.textline.TextLineCodecFactory; import org.apache.mina.filter.logging.LoggingFilter; import org.apache.mina.transport.socket.nio.NioSocketConnector; import org.apache.mina.core.session.IoSession; import org.apache.mina.core.future.*; public class TC4HostClient { private static final int PORT = 9123; public static void main( String[] args ) throws IOException,Exception { NioSocketConnector connector = new NioSocketConnector(); SocketAddress address = new InetSocketAddress("172.16.25.3", 8004); connector.getSessionConfig().setReadBufferSize( 2048 ); connector.getFilterChain().addLast( "logger", new LoggingFilter() ); connector.getFilterChain().addLast( "codec", new ProtocolCodecFilter( new TextLineCodecFactory( Charset.forName( "UTF-8" )))); connector.setHandler(new TC4HostClientHandler()); ConnectFuture future1 = connector.connect(address); future1.awaitUninterruptibly(); if (!future1.isConnected()) { return ; } IoSession session = future1.getSession(); System.out.println("CGS Sign On"); session.getConfig().setUseReadOperation(true); session.write(" 00000333CST 1001010 00000308000003080010000000009600000000FTS O00000146TC4DS 001WSJTC41 ---001NTMU9001-I --------000 0030000000012400000096500007013082015SATYA 500000 010165070000002200011 01800000000022000001241 172.16.25.122 02"); session.getCloseFuture().awaitUninterruptibly(); System.out.println("After Writing"); connector.dispose(); } } import org.apache.mina.core.session.IdleStatus; import org.apache.mina.core.service.IoHandlerAdapter; import org.apache.mina.core.session.IoSession; import org.apache.mina.core.buffer.IoBuffer; public class TC4HostClientHandler extends IoHandlerAdapter { @Override public void exceptionCaught( IoSession session, Throwable cause ) throws Exception { cause.printStackTrace(); } @Override public void messageSent( IoSession session, Object message ) throws Exception { String str = message.toString(); System.out.println("Message Sent" + str); } @Override public void messageReceived( IoSession session, Object message ) throws Exception { IoBuffer buf = (IoBuffer) message; // Print out read buffer content. while (buf.hasRemaining()) { System.out.print((char) buf.get()); } System.out.flush(); } /* @Override public void messageReceived( IoSession session, Object message ) throws Exception { String str = message.toString(); System.out.println("Message Received : " + str); }*/ @Override public void sessionIdle( IoSession session, IdleStatus status ) throws Exception { System.out.println( "IDLE " + session.getIdleCount( status )); } public void sessionClosed(IoSession session){ System.out.println( "Closed "); } public void sessionOpened(IoSession session){ System.out.println( "Opened "); } }

    Read the article

  • Java NIO SocketChannel writing problem

    - by Nilesh
    I am using Java NIO's SocketChannel to write : int n = socketChannel.write(byteBuffer); Most of the times the data is sent in one or two parts; i.e. if the data could not be sent in one attemmpt, remaining data is retried. The issue here is, sometimes, the data is not being sent completely in one attempt, rest of the data when tried to send multiple times, it occurs that even after trying several times, not a single character is being written to channel, finally after some time the remaning data is sent. What could be the cause of such behaviour? Could external factors such as RAM, etc cause the hindarance? Please help me solve this issue. If any other information is required please let me know. Thanks

    Read the article

  • Fast 4x4 matrix multiplication in Java with NIO float buffers

    - by kayahr
    I know there are LOT of questions like that but I can't find one specific to my situation. I have 4x4 matrices implemented as NIO float buffers (These matrices are used for OpenGL). Now I want to implement a multiply method which multiplies Matrix A with Matrix B and stores the result in Matrix C. So the code may look like this: class Matrix4f { private FloatBuffer buffer = FloatBuffer.allocate(16); public Matrix4f multiply(Matrix4f matrix2, Matrix4f result) { {{{result = this * matrix2}}} <-- I need this code return result; } } What is the fastest possible code to do this multiplication? Some OpenGL implementations (Like the OpenGL ES stuff in Android) provide native code for this but others doesn't. So I want to provide a generic multiplication method for these implementations.

    Read the article

  • Java NIO (Netty): How does Encryption or GZIPping work in theory (with filters)

    - by Tom
    Hello Experts, i would be very thankfull if you can explain to me, how in theory the "Interceptor/Filter" Pattern in ByteStreams (over Sockets/Channels) work (in Asynchronous IO with netty) in regard to encryption or compression of data. Given I have a Filter that does GZIPPING. How is this internally implemented? Does the Filter "collect" so many bytes form the channel, that this is a usefull number of bytes that can then be en/decoded? What is in general the minimal "blocksize(data to encode/decode in a chunk)" of socket based gzipping? Does this "blocksize" have to be negotiated in advance between server and client? What happens if the client does not send enough data to "fill" the blocksize (due to a network conquestion) but does not close the connection. Does this mean the other side will simply wait until it gets enough bytes to decode or until a timeout occoures...How is the Filter pattern the applied? The compression filter will de/compress the blocksize of bytes and then store them again in the same buffer would (in the case of netty) i normally be using the ChannelHanlderContext to pass the de/encoded data to the next filter?... Any explanations/links/tutorials (for beginners;-) will be very much appreciated to help me understand how for example encryption/compressing are implemented in socket based communication with filters/interceptor pattern. thank you very much tom

    Read the article

  • Specify connection timeout in java.nio

    - by miorel
    Using non-blocking I/O, the code for connecting to a remote address looks something like: SocketChannel channel = SelectorProvider.provider().openSocketChannel(); channel.configureBlocking(false); channel.connect(address); The connection process will then have to be finished by invoking finishConnect() on the channel when some selector says the corresponding key isConnectable(). Is there a way to specify the connection timeout when using this idiom?

    Read the article

  • long polling netty nio framework java

    - by Alfred
    Hi, How can I do long-polling using netty framework? Say for example I fetch http://localhost/waitforx but waitforx is asynchronous because it has to wait for an event? Say for example it fetches something from a blocking queue(can only fetch when data in queue). When getting item from queue I would like to sent data back to client. Hopefully somebody can give me some tips how to do this. Many thanks

    Read the article

  • Java NIO (Netty): Exceptionhandling in Downstream Hanlders/Chain

    - by Tom
    Hello Experts, could someone please explain to me, how in netty "Downstream Exceptions" are handeled? According to the javadoc there are no Downstream exceptions: http://docs.jboss.org/netty/3.1/api/org/jboss/netty/channel/ExceptionEvent.html Given the case that in one of my downstream handlers an exception occures OR in the I/0 Thread itself, where can these errors be catched and handeled? thank you very much tom

    Read the article

  • "ERROR:Could not find java.nio.file.Paths" when using Oracle JDK 1.7

    - by Ankit
    I want to try out some features rolled out in Oracle's new JDK 1.7. I followed the post:- Oracle JDK 1.7 but the post doesn't seem to help. I was trying to fetch out the structure for java.nio.file.Paths class file but got the following error:- buffer@ankit:~$ javap java.nio.file.Paths ERROR:Could not find java.nio.file.Paths However i can easily get the information about class structures till JAVA SE 1.6, here is an example:- buffer@ankit:~$ javap java.lang.Object Compiled from "Object.java" public class java.lang.Object{ public java.lang.Object(); public final native java.lang.Class getClass(); public native int hashCode(); public boolean equals(java.lang.Object); protected native java.lang.Object clone() throws java.lang.CloneNotSupportedException; public java.lang.String toString(); public final native void notify(); public final native void notifyAll(); public final native void wait(long) throws java.lang.InterruptedException; public final void wait(long, int) throws java.lang.InterruptedException; public final void wait() throws java.lang.InterruptedException; protected void finalize() throws java.lang.Throwable; static {}; } Running java -version gives the following result:- buffer@ankit:~$ java -version java version "1.7.0_09" Java(TM) SE Runtime Environment (build 1.7.0_09-b05) Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode) SYSTEM INFORMATION buffer@ankit:~$ sudo update-alternatives --config java [sudo] password for buffer: There are 4 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode 1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode 2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode 3 /usr/lib/jvm/jdk1.7.0_09/ 1 manual mode * 4 /usr/lib/jvm/jdk1.7.0_09/bin/java 1 manual mode buffer@ankit:~$ sudo update-alternatives --config javac There are 2 choices for the alternative javac (providing /usr/bin/javac). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-6-openjdk-amd64/bin/javac 1061 auto mode 1 /usr/lib/jvm/java-6-openjdk-amd64/bin/javac 1061 manual mode * 2 /usr/lib/jvm/jdk1.7.0_09/bin/javac 1 manual mode buffer@ankit:~$ sudo update-alternatives --config javaws There are 3 choices for the alternative javaws (providing /usr/bin/javaws). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws 1061 auto mode 1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws 1061 manual mode 2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws 1060 manual mode * 3 /usr/lib/jvm/jdk1.7.0_09/bin/javaws 1 manual mode The directory structure of /usr/lib/jvm/ is as follows:- buffer@ankit:~$ ls -l /usr/lib/jvm/ total 24 lrwxrwxrwx 1 root root 24 Dec 2 2011 default-java -> java-1.6.0-openjdk-amd64 drwxr-xr-x 4 root root 4096 Nov 8 16:24 java-1.5.0-gcj-4.6 lrwxrwxrwx 1 root root 24 Dec 2 2011 java-1.6.0-openjdk -> java-1.6.0-openjdk-amd64 lrwxrwxrwx 1 root root 20 Oct 25 00:01 java-1.6.0-openjdk-amd64 -> java-6-openjdk-amd64 lrwxrwxrwx 1 root root 20 Oct 25 06:59 java-1.7.0-openjdk-amd64 -> java-7-openjdk-amd64 lrwxrwxrwx 1 root root 24 Dec 2 2011 java-6-openjdk -> java-1.6.0-openjdk-amd64 drwxr-xr-x 7 root root 4096 Nov 8 16:24 java-6-openjdk-amd64 drwxr-xr-x 3 root root 4096 Nov 8 16:24 java-6-openjdk-common drwxr-xr-x 5 root root 4096 Nov 8 05:48 java-7-openjdk-amd64 drwxr-xr-x 3 root root 4096 Nov 8 05:48 java-7-openjdk-common drwxr-xr-x 8 buffer buffer 4096 Sep 25 09:08 jdk1.7.0_09 Any help would be highly appreciated.

    Read the article

  • Java map / nio / NFS issue causing a VM fault: "a fault occurred in a recent unsafe memory access op

    - by Matthew Bloch
    I have written a parser class for a particular binary format (nfdump if anyone is interested) which uses java.nio's MappedByteBuffer to read through files of a few GB each. The binary format is just a series of headers and mostly fixed-size binary records, which are fed out to the called by calling nextRecord(), which pushes on the state machine, returning null when it's done. It performs well. It works on a development machine. On my production host, it can run for a few minutes or hours, but always seems to throw "java.lang.InternalError: a fault occurred in a recent unsafe memory access operation in compiled Java code", fingering one of the Map.getInt, getShort methods, i.e. a read operation in the map. The uncontroversial (?) code that sets up the map is this: /** Set up the map from the given filename and position */ protected void open() throws IOException { // Set up buffer, is this all the flexibility we'll need? channel = new FileInputStream(file).getChannel(); MappedByteBuffer map1 = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()); map1.load(); // we want the whole thing, plus seems to reduce frequency of crashes? map = map1; // assumes the host writing the files is little-endian (x86), ought to be configurable map.order(java.nio.ByteOrder.LITTLE_ENDIAN); map.position(position); } and then I use the various map.get* methods to read shorts, ints, longs and other sequences of bytes, before hitting the end of the file and closing the map. I've never seen the exception thrown on my development host. But the significant point of difference between my production host and development is that on the former, I am reading sequences of these files over NFS (probably 6-8TB eventually, still growing). On my dev machine, I have a smaller selection of these files locally (60GB), but when it blows up on the production host it's usually well before it gets to 60GB of data. Both machines are running java 1.6.0_20-b02, though the production host is running Debian/lenny, the dev host is Ubuntu/karmic. I'm not convinced that will make any difference. Both machines have 16GB RAM, and are running with the same java heap settings. I take the view that if there is a bug in my code, there is enough of a bug in the JVM not to throw me a proper exception! But I think it is just a particular JVM implementation bug due to interactions between NFS and mmap, possibly a recurrence of 6244515 which is officially fixed. I already tried adding in a "load" call to force the MappedByteBuffer to load its contents into RAM - this seemed to delay the error in the one test run I've done, but not prevent it. Or it could be coincidence that was the longest it had gone before crashing! If you've read this far and have done this kind of thing with java.nio before, what would your instinct be? Right now mine is to rewrite it without nio :)

    Read the article

1 2 3 4 5 6 7  | Next Page >