a bug in tightvnc java library

I found a bug for the tightvnc java library, if my setup like this

tightvnc (java) -> java proxy server -> java proxy server -> vnc server

IT doesn’t work, after I trace the code, this could caused by this line:

this.is = new DataInputStream(new BufferedInputStream(is));

In Reader.java constructor, it is called twice. You can see that if you set a breakpoint in doInBackground() in SwingRfbConnectionWorker. The BufferedInputStream will cache the bytes immediately, so if it is called two times, the cached bytes will exist in one reader instance only. So I think this is the root cause.

To fix it, please change the code to “private static DataInputStream is;”, I changed the “DataInputStream is;” to static, so make sure the buffered bytes are cached into same stream, then the bug gone.


read count : 635


  1. I was wrong. The author of that library told me the Reader should be only instance once. It was my mistake to make it instance twice. But I have fixed it, the correct code should be :

    public static void initVNCPanel(WindowListener windowListener, JPanel vncPanel, String host, int port, String password) {
    Viewer viewer = new Viewer();
    try {
    ProtocolSettings rfbSettings = ProtocolSettings.getDefaultSettings();

    UiSettings uiSettings = new UiSettings();

    boolean hasJsch = true;
    boolean allowInteractive = false;//allowAppletInteractiveConnections || ! isApplet;
    ConnectionPresenter connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive);
    ConnectionParams connectionParams = new ConnectionParams();
    connectionParams.hostName = host;
    connectionPresenter.addModel(“ConnectionParamsModel”, connectionParams);
    final ConnectionView connectionView = new ConnectionView(windowListener, connectionPresenter, hasJsch);

    connectionPresenter.addView(ConnectionPresenter.CONNECTION_VIEW, connectionView);

    SwingViewerWindowFactory viewerWindowFactory = new SwingViewerWindowFactory(true, false, viewer);
    viewerWindowFactory.vncPanel = vncPanel;
    connectionPresenter.setConnectionWorkerFactory(new SwingConnectionWorkerFactory(connectionView.getFrame(), password, connectionPresenter, viewerWindowFactory));
    connectionPresenter.startConnection(rfbSettings, uiSettings, 0);
    } catch (Exception ex) {

  2. Hi,Peter! Last week you mentioned that there will be a more accurate compile guide this Monday.Where can I see it?