java.io.IOException: Stream Closed

Wednesday, 10 June 2015 · 3 messages
KF
Ketill Fenne10 Jun 2015 10:46 #
Hi! From time to time I see the following error:
java.io.IOException: Stream Closed
        at java.io.RandomAccessFile.seek0(Native Method)
        at java.io.RandomAccessFile.seek(RandomAccessFile.java:557)
        at
org.basex.io.random.TableDiskAccess.readBlock(TableDiskAccess.java:520)
        at
org.basex.io.random.TableDiskAccess.readPage(TableDiskAccess.java:485)
        at
org.basex.io.random.TableDiskAccess.cursor(TableDiskAccess.java:464)
        at
org.basex.io.random.TableDiskAccess.read1(TableDiskAccess.java:148)
        at org.basex.data.Data.kind(Data.java:307)
        at org.basex.query.value.node.DBNode$4.next(DBNode.java:349)
        at org.basex.query.expr.path.IterStep$1.next(IterStep.java:38)
        at org.basex.query.expr.path.IterStep$1.next(IterStep.java:32)
        at org.basex.query.expr.path.IterPath$1.next(IterPath.java:58)
        at org.basex.query.expr.path.IterPath$1.next(IterPath.java:36)
        at org.basex.query.expr.gflwor.For$1.next(For.java:79)
        at org.basex.query.expr.gflwor.GFLWOR$1.next(GFLWOR.java:95)
        at org.basex.query.MainModule$1.next(MainModule.java:114)
        at org.basex.server.ServerQuery.execute(ServerQuery.java:130)
        at org.basex.api.client.LocalQuery.cache(LocalQuery.java:48)
        at org.basex.api.client.Query.more(Query.java:76)
An example of how I query and iterate:
        DBResult dbResult = null;
        LocalQuery results = null;
        try {
            xPath = xPath.indexOf("/") == -1 ? "/" + xPath : xPath;
            String myQuery = "for $doc in (" +
getContentCollectionQuery(PPSCONTENT_DATABASE_NAME) + " ) " + xPath +
createNameCondition(name, PPSCONTENT_DATABASE_NAME) +
createDateCondition(version) + " " +
            " return (data($doc/topic/@id))";
            dbResult = runQuery(myQuery);
            results = dbResult.getXmlResults();
            String topic = null;
            if (results.more()) {
                topic = results.next();
            }
            return topic;
        } catch (QueryException e) {
            PPLogger.getInstance().error("Error in getTopicForDocWithName:
" + e.getMessage());
            return null;
        } catch (IOException e) {
            PPLogger.getInstance().error("Error in getTopicForDocWithName:
" + e.getMessage());
            return null;
        }
        finally {
            if (results != null) results.close();
            if (dbResult != null) dbResult.close();
        }
The error occurs randomly, but is always "triggered" by "results.more()" and I am not able to reproduce it at will. Is there something wrong or missing in how I iterate the results? I am using BaseX8.2.1 on windows 7. Kind regards Ketill Fenne
CG
Christian Grün10 Jun 2015 11:49 #
Hi Ketill,
Quoted text · Ketill Fenne · 3 lines
> The error occurs randomly, but is always "triggered" by "results.more()" and > I am not able to reproduce it at will. Is there something wrong or missing > in how I iterate the results?
If you want, you can pass me the missing Java functions, as I not know too little about what e.g. getXmlResult does. Ideally, of course, we would be happy to have a self-contained example that we can test. Best, Christian
Quoted text · Ketill Fenne · 5 lines
> I am using BaseX8.2.1 on windows 7. > > Kind regards > Ketill Fenne >
KF
Ketill Fenne10 Jun 2015 12:00 #
Hi! This is the runQuery method:
    static Context context = new Context();
    static LocalSession session = new LocalSession(context);

    public DBResult runQuery(String query) throws QueryException {
        try {
            LocalQuery lq = session.query(query);
            DBResult db = new DBResult(lq);
            return db;
        } catch (Exception e) {
            PPLogger.getInstance().error("Error in runQuery: " +
e.getMessage(), e);
            throw e;
        }
    }
and this is the relevant part of the DBResult class: ************************************************************************************************ private LocalQuery results;
    public DBResult(LocalQuery results) {
        Assertion.assertNotNull(results, "Results are null");
        this.results = results;
    }
public LocalQuery getXmlResults() { return results; } ************************************************************************************************ As I mention, I am not able to give an example that will reproduce the error every time, but it seems to occur randomly, and not very often :-( Ketill
Quoted text · Christian Grün · 24 lines
On Wed, Jun 10, 2015 at 11:49 AM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Ketill, > > > The error occurs randomly, but is always "triggered" by "results.more()" > and > > I am not able to reproduce it at will. Is there something wrong or > missing > > in how I iterate the results? > > If you want, you can pass me the missing Java functions, as I not know > too little about what e.g. getXmlResult does. Ideally, of course, we > would be happy to have a self-contained example that we can test. > > Best, > Christian > > > > I am using BaseX8.2.1 on windows 7. > > > > Kind regards > > Ketill Fenne > > >

⚡Generated with XQuery