package de.javakaffee.kryoserializers;

import java.util.regex.Pattern;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;

public class RegexSerializer extends Serializer<Pattern> {

    public RegexSerializer() {
        setImmutable(true);
    }

    @Override
    public void write(final Kryo kryo, final Output output, final Pattern pattern) {
        output.writeString(pattern.pattern());
    }

    @Override
    public Pattern read(final Kryo kryo, final Input input, final Class<Pattern> patternClass) {
        return Pattern.compile(input.readString());
    }
}

@@ -238,16 +238,188 @@
 utput;%0A%0A
+/**%0A * Kryo %7B@link Serializer%7D for regex %7B@link Pattern%7Ds.%0A * %0A * @author %3Ca href=%22mailto:martin.grotzke@javakaffee.de%22%3EMartin Grotzke%3C/a%3E%0A * @author serverperformance%0A */%0A
 public c
@@ -678,24 +678,72 @@
 pattern());%0A
+        output.writeInt(pattern.flags(), true);%0A
     %7D%0A%0A    @
@@ -844,24 +844,108 @@
 ernClass) %7B%0A
+        String regex = input.readString();%0A        int flags = input.readInt(true);%0A
         retu
@@ -963,34 +963,28 @@
 compile(
-input.readString()
+regex, flags
 );%0A    %7D

Fix to RegexSerializer