Search in sources :

Example 1 with ObjectOutput

use of java.io.ObjectOutput in project hibernate-orm by hibernate.

the class JpaDescriptorParser method saveTimeStampCache.

private void saveTimeStampCache(FileTimeStampChecker fileStampCheck) {
    try {
        File file = getSerializationTmpFile();
        ObjectOutput out = new ObjectOutputStream(new FileOutputStream(file));
        out.writeObject(fileStampCheck);
        out.close();
        context.logMessage(Diagnostic.Kind.OTHER, "Serialized " + fileStampCheck + " into " + file.getAbsolutePath());
    } catch (IOException e) {
        // ignore - if the serialization failed we just have to keep parsing the xml
        context.logMessage(Diagnostic.Kind.OTHER, "Error serializing  " + fileStampCheck);
    }
}
Also used : ObjectOutput(java.io.ObjectOutput) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream) File(java.io.File)

Example 2 with ObjectOutput

use of java.io.ObjectOutput in project lucene-solr by apache.

the class TestRegExp method testSerializeTooManyStatesToDeterminizeExc.

// LUCENE-6713
public void testSerializeTooManyStatesToDeterminizeExc() throws Exception {
    // LUCENE-6046
    String source = "[ac]*a[ac]{50,200}";
    TooComplexToDeterminizeException expected = expectThrows(TooComplexToDeterminizeException.class, () -> {
        new RegExp(source).toAutomaton();
    });
    assertTrue(expected.getMessage().contains(source));
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutput out = new ObjectOutputStream(bos);
    out.writeObject(expected);
    byte[] bytes = bos.toByteArray();
    ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
    ObjectInput in = new ObjectInputStream(bis);
    TooComplexToDeterminizeException e2 = (TooComplexToDeterminizeException) in.readObject();
    assertNotNull(e2.getMessage());
}
Also used : ObjectOutput(java.io.ObjectOutput) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectInput(java.io.ObjectInput) ObjectOutputStream(java.io.ObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 3 with ObjectOutput

use of java.io.ObjectOutput in project jackrabbit-oak by apache.

the class AbstractDataStoreCacheTest method serializeMap.

static void serializeMap(Map<String, Long> pendingupload, File file) throws IOException {
    OutputStream fos = new FileOutputStream(file);
    OutputStream buffer = new BufferedOutputStream(fos);
    ObjectOutput output = new ObjectOutputStream(buffer);
    try {
        output.writeObject(pendingupload);
        output.flush();
    } finally {
        output.close();
        IOUtils.closeQuietly(buffer);
    }
}
Also used : ObjectOutput(java.io.ObjectOutput) BufferedOutputStream(java.io.BufferedOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) BufferedOutputStream(java.io.BufferedOutputStream)

Example 4 with ObjectOutput

use of java.io.ObjectOutput in project sessdb by ppdai.

the class SampleValue method toBytes.

public byte[] toBytes() throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutput out = null;
    try {
        out = new ObjectOutputStream(bos);
        out.writeObject(this);
        byte[] yourBytes = bos.toByteArray();
        return yourBytes;
    } finally {
        try {
            if (out != null) {
                out.close();
            }
        } catch (IOException ex) {
        // ignore close exception
        }
        try {
            bos.close();
        } catch (IOException ex) {
        // ignore close exception
        }
    }
}
Also used : ObjectOutput(java.io.ObjectOutput) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream)

Example 5 with ObjectOutput

use of java.io.ObjectOutput in project quasar by puniverse.

the class JDKSerializer method write.

@Override
public void write(OutputStream os, Object object) throws IOException {
    final ObjectOutput oo = toObjectOutput(os);
    oo.writeObject(object);
}
Also used : ObjectOutput(java.io.ObjectOutput)

Aggregations

ObjectOutput (java.io.ObjectOutput)105 ObjectOutputStream (java.io.ObjectOutputStream)78 ByteArrayOutputStream (java.io.ByteArrayOutputStream)64 IOException (java.io.IOException)53 ObjectInput (java.io.ObjectInput)26 Test (org.junit.Test)24 ObjectInputStream (java.io.ObjectInputStream)20 ByteArrayInputStream (java.io.ByteArrayInputStream)19 WorkingMemory (org.drools.core.WorkingMemory)13 FileOutputStream (java.io.FileOutputStream)12 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)12 Pattern (org.drools.core.rule.Pattern)12 Consequence (org.drools.core.spi.Consequence)12 KnowledgeHelper (org.drools.core.spi.KnowledgeHelper)12 OutputStream (java.io.OutputStream)11 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)8 Declaration (org.drools.core.rule.Declaration)8 IntrospectionException (java.beans.IntrospectionException)7 File (java.io.File)7 InvalidRuleException (org.drools.core.rule.InvalidRuleException)7