You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Matthias Seidel (JIRA)" <ji...@apache.org> on 2007/01/26 14:51:49 UTC

[jira] Created: (LUCENE-785) RAMDirectory not Serializable

RAMDirectory not Serializable
-----------------------------

                 Key: LUCENE-785
                 URL: https://issues.apache.org/jira/browse/LUCENE-785
             Project: Lucene - Java
          Issue Type: Bug
          Components: Store
    Affects Versions: 2.1
            Reporter: Matthias Seidel
            Priority: Minor


The current implementation of RAMDirectory throws a NotSerializableException when trying to serialize, due to the inner class KeySet of HashMap not being serializable (god knows why)

java.io.NotSerializableException: java.util.HashMap$KeySet
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)

Caused by line 43:

private Set fileNames = fileMap.keySet();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Resolved: (LUCENE-785) RAMDirectory not Serializable

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-785?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael McCandless resolved LUCENE-785.
---------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.1

> RAMDirectory not Serializable
> -----------------------------
>
>                 Key: LUCENE-785
>                 URL: https://issues.apache.org/jira/browse/LUCENE-785
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 2.1
>            Reporter: Matthias Seidel
>         Assigned To: Michael McCandless
>            Priority: Minor
>             Fix For: 2.1
>
>         Attachments: ramdir.serializable.diff
>
>
> The current implementation of RAMDirectory throws a NotSerializableException when trying to serialize, due to the inner class KeySet of HashMap not being serializable (god knows why)
> java.io.NotSerializableException: java.util.HashMap$KeySet
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Caused by line 43:
> private Set fileNames = fileMap.keySet();
> EDIT:
> while we're at it: same goes for inner class Values 
> java.io.NotSerializableException: java.util.HashMap$Values
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Collection files = fileMap.values();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Updated: (LUCENE-785) RAMDirectory not Serializable

Posted by "Hoss Man (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-785?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hoss Man updated LUCENE-785:
----------------------------

    Attachment: ramdir.serializable.diff

maybe i'm missing something, but this seema like a trivail fix ... HashMap is serializable -- it's just the persistent refrences to the keySet() and values() Collections that arne't serializable (fileNames and files)

One is private, the other is package protected, so why don't we just get ride of them and fetch as needed?  (files isn't even used except in a Mock subclass for testing purposes)

> RAMDirectory not Serializable
> -----------------------------
>
>                 Key: LUCENE-785
>                 URL: https://issues.apache.org/jira/browse/LUCENE-785
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 2.1
>            Reporter: Matthias Seidel
>         Assigned To: Michael McCandless
>            Priority: Minor
>         Attachments: ramdir.serializable.diff
>
>
> The current implementation of RAMDirectory throws a NotSerializableException when trying to serialize, due to the inner class KeySet of HashMap not being serializable (god knows why)
> java.io.NotSerializableException: java.util.HashMap$KeySet
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Caused by line 43:
> private Set fileNames = fileMap.keySet();
> EDIT:
> while we're at it: same goes for inner class Values 
> java.io.NotSerializableException: java.util.HashMap$Values
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Collection files = fileMap.values();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Updated: (LUCENE-785) RAMDirectory not Serializable

Posted by "Matthias Seidel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-785?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matthias Seidel updated LUCENE-785:
-----------------------------------

    Description: 
The current implementation of RAMDirectory throws a NotSerializableException when trying to serialize, due to the inner class KeySet of HashMap not being serializable (god knows why)

java.io.NotSerializableException: java.util.HashMap$KeySet
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)

Caused by line 43:

private Set fileNames = fileMap.keySet();

EDIT:

while we're at it: same goes for inner class Values 

java.io.NotSerializableException: java.util.HashMap$Values
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)

Collection files = fileMap.values();


  was:
The current implementation of RAMDirectory throws a NotSerializableException when trying to serialize, due to the inner class KeySet of HashMap not being serializable (god knows why)

java.io.NotSerializableException: java.util.HashMap$KeySet
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)

Caused by line 43:

private Set fileNames = fileMap.keySet();


> RAMDirectory not Serializable
> -----------------------------
>
>                 Key: LUCENE-785
>                 URL: https://issues.apache.org/jira/browse/LUCENE-785
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 2.1
>            Reporter: Matthias Seidel
>            Priority: Minor
>
> The current implementation of RAMDirectory throws a NotSerializableException when trying to serialize, due to the inner class KeySet of HashMap not being serializable (god knows why)
> java.io.NotSerializableException: java.util.HashMap$KeySet
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Caused by line 43:
> private Set fileNames = fileMap.keySet();
> EDIT:
> while we're at it: same goes for inner class Values 
> java.io.NotSerializableException: java.util.HashMap$Values
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Collection files = fileMap.values();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Assigned: (LUCENE-785) RAMDirectory not Serializable

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-785?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael McCandless reassigned LUCENE-785:
-----------------------------------------

    Assignee: Michael McCandless

> RAMDirectory not Serializable
> -----------------------------
>
>                 Key: LUCENE-785
>                 URL: https://issues.apache.org/jira/browse/LUCENE-785
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 2.1
>            Reporter: Matthias Seidel
>         Assigned To: Michael McCandless
>            Priority: Minor
>
> The current implementation of RAMDirectory throws a NotSerializableException when trying to serialize, due to the inner class KeySet of HashMap not being serializable (god knows why)
> java.io.NotSerializableException: java.util.HashMap$KeySet
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Caused by line 43:
> private Set fileNames = fileMap.keySet();
> EDIT:
> while we're at it: same goes for inner class Values 
> java.io.NotSerializableException: java.util.HashMap$Values
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Collection files = fileMap.values();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-785) RAMDirectory not Serializable

Posted by "Karl Wettin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-785?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12467831 ] 

Karl Wettin commented on LUCENE-785:
------------------------------------

Hmm, this must be something fairly new. I had no problems when Serializable was introduced back in LUCENE-601. 

> RAMDirectory not Serializable
> -----------------------------
>
>                 Key: LUCENE-785
>                 URL: https://issues.apache.org/jira/browse/LUCENE-785
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 2.1
>            Reporter: Matthias Seidel
>            Priority: Minor
>
> The current implementation of RAMDirectory throws a NotSerializableException when trying to serialize, due to the inner class KeySet of HashMap not being serializable (god knows why)
> java.io.NotSerializableException: java.util.HashMap$KeySet
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Caused by line 43:
> private Set fileNames = fileMap.keySet();
> EDIT:
> while we're at it: same goes for inner class Values 
> java.io.NotSerializableException: java.util.HashMap$Values
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Collection files = fileMap.values();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-785) RAMDirectory not Serializable

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-785?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12468061 ] 

Michael McCandless commented on LUCENE-785:
-------------------------------------------

I agree, and your fix looks great!  I will commit it.  Thanks Hoss.

> RAMDirectory not Serializable
> -----------------------------
>
>                 Key: LUCENE-785
>                 URL: https://issues.apache.org/jira/browse/LUCENE-785
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 2.1
>            Reporter: Matthias Seidel
>         Assigned To: Michael McCandless
>            Priority: Minor
>         Attachments: ramdir.serializable.diff
>
>
> The current implementation of RAMDirectory throws a NotSerializableException when trying to serialize, due to the inner class KeySet of HashMap not being serializable (god knows why)
> java.io.NotSerializableException: java.util.HashMap$KeySet
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Caused by line 43:
> private Set fileNames = fileMap.keySet();
> EDIT:
> while we're at it: same goes for inner class Values 
> java.io.NotSerializableException: java.util.HashMap$Values
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Collection files = fileMap.values();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-785) RAMDirectory not Serializable

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-785?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12467838 ] 

Michael McCandless commented on LUCENE-785:
-------------------------------------------

OK, here's a quick unit test that catches the regression:

    public void testSerializable() throws IOException {
        Directory dir = new RAMDirectory();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(bos);
        out.writeObject(dir);
        out.close();
    }

Using this I tracked down the commit that caused serializability to break:

    http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/store/RAMDirectory.java?p2=%2Flucene%2Fjava%2Ftrunk%2Fsrc%2Fjava%2Forg%2Fapache%2Flucene%2Fstore%2FRAMDirectory.java&p1=%2Flucene%2Fjava%2Ftrunk%2Fsrc%2Fjava%2Forg%2Fapache%2Flucene%2Fstore%2FRAMDirectory.java&r1=478014&r2=478013&view=diff&pathrev=478014

This commit was for LUCENE-709

> RAMDirectory not Serializable
> -----------------------------
>
>                 Key: LUCENE-785
>                 URL: https://issues.apache.org/jira/browse/LUCENE-785
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 2.1
>            Reporter: Matthias Seidel
>            Priority: Minor
>
> The current implementation of RAMDirectory throws a NotSerializableException when trying to serialize, due to the inner class KeySet of HashMap not being serializable (god knows why)
> java.io.NotSerializableException: java.util.HashMap$KeySet
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Caused by line 43:
> private Set fileNames = fileMap.keySet();
> EDIT:
> while we're at it: same goes for inner class Values 
> java.io.NotSerializableException: java.util.HashMap$Values
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Collection files = fileMap.values();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-785) RAMDirectory not Serializable

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-785?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12468014 ] 

Michael McCandless commented on LUCENE-785:
-------------------------------------------

Alas, it looks like HashMap.keySet() and .values() are just not serializable, and never will be:

    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4501848

I think keeping serialization for RAMDirectory is important.

> RAMDirectory not Serializable
> -----------------------------
>
>                 Key: LUCENE-785
>                 URL: https://issues.apache.org/jira/browse/LUCENE-785
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 2.1
>            Reporter: Matthias Seidel
>            Priority: Minor
>
> The current implementation of RAMDirectory throws a NotSerializableException when trying to serialize, due to the inner class KeySet of HashMap not being serializable (god knows why)
> java.io.NotSerializableException: java.util.HashMap$KeySet
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Caused by line 43:
> private Set fileNames = fileMap.keySet();
> EDIT:
> while we're at it: same goes for inner class Values 
> java.io.NotSerializableException: java.util.HashMap$Values
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Collection files = fileMap.values();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-785) RAMDirectory not Serializable

Posted by "Daniel Bechler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-785?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12467832 ] 

Daniel Bechler commented on LUCENE-785:
---------------------------------------

That's what I heared from Matthias, too. (We work in the same company.) There were no problems with earlier versions of Lucene 2.1.

> RAMDirectory not Serializable
> -----------------------------
>
>                 Key: LUCENE-785
>                 URL: https://issues.apache.org/jira/browse/LUCENE-785
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 2.1
>            Reporter: Matthias Seidel
>            Priority: Minor
>
> The current implementation of RAMDirectory throws a NotSerializableException when trying to serialize, due to the inner class KeySet of HashMap not being serializable (god knows why)
> java.io.NotSerializableException: java.util.HashMap$KeySet
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Caused by line 43:
> private Set fileNames = fileMap.keySet();
> EDIT:
> while we're at it: same goes for inner class Values 
> java.io.NotSerializableException: java.util.HashMap$Values
>         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> Collection files = fileMap.values();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org