Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A14EDD86A for ; Thu, 20 Sep 2012 18:14:13 +0000 (UTC) Received: (qmail 85597 invoked by uid 500); 20 Sep 2012 18:14:13 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 85588 invoked by uid 99); 20 Sep 2012 18:14:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Sep 2012 18:14:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Sep 2012 18:14:12 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 300C923888E4; Thu, 20 Sep 2012 18:13:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1388150 - /lucene/dev/branches/solr3733/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java Date: Thu, 20 Sep 2012 18:13:29 -0000 To: commits@lucene.apache.org From: uschindler@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120920181329.300C923888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: uschindler Date: Thu Sep 20 18:13:28 2012 New Revision: 1388150 URL: http://svn.apache.org/viewvc?rev=1388150&view=rev Log: SOLR-3733: Fix NPE, now it seems to work - sorry Modified: lucene/dev/branches/solr3733/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java Modified: lucene/dev/branches/solr3733/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr3733/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java?rev=1388150&r1=1388149&r2=1388150&view=diff ============================================================================== --- lucene/dev/branches/solr3733/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java (original) +++ lucene/dev/branches/solr3733/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java Thu Sep 20 18:13:28 2012 @@ -19,7 +19,6 @@ package org.apache.solr.common.cloud; import java.io.IOException; import java.lang.reflect.Field; -import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; @@ -45,16 +44,6 @@ public class SolrZooKeeper extends ZooKe return cnxn; } - SelectableChannel getSendThreadChannel() throws Exception { - final Field sendThreadFld = cnxn.getClass().getDeclaredField("sendThread"); - sendThreadFld.setAccessible(true); - Object sendThread = sendThreadFld.get(cnxn); - final Field sockKeyFld = sendThread.getClass().getDeclaredField("sockKey"); - sockKeyFld.setAccessible(true); - final SelectionKey sockKey = (SelectionKey) sockKeyFld.get(sendThread); - return sockKey.channel(); - } - /** * Cause this ZooKeeper object to stop receiving from the ZooKeeperServer * for the given number of milliseconds. @@ -64,9 +53,20 @@ public class SolrZooKeeper extends ZooKe final Thread t = new Thread() { public void run() { try { + final ClientCnxn cnxn = getConnection(); synchronized (cnxn) { try { - getSendThreadChannel().close(); + final Field sendThreadFld = cnxn.getClass().getDeclaredField("sendThread"); + sendThreadFld.setAccessible(true); + Object sendThread = sendThreadFld.get(cnxn); + if (sendThread != null) { + final Field sockKeyFld = sendThread.getClass().getDeclaredField("sockKey"); + sockKeyFld.setAccessible(true); + final SelectionKey sockKey = (SelectionKey) sockKeyFld.get(sendThread); + if (sockKey != null) { + sockKey.channel().close(); + } + } } catch (Exception e) { throw new RuntimeException("Closing Zookeeper send channel failed.", e); }