Index: lucene/analysis/common/src/java/org/apache/lucene/analysis/th/ThaiWordFilter.java
===================================================================
--- lucene/analysis/common/src/java/org/apache/lucene/analysis/th/ThaiWordFilter.java	(révision 1479915)
+++ lucene/analysis/common/src/java/org/apache/lucene/analysis/th/ThaiWordFilter.java	(copie de travail)
@@ -1,12 +1,13 @@
 package org.apache.lucene.analysis.th;
 
-/**
- * Copyright 2006 The Apache Software Foundation
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
@@ -37,6 +38,8 @@
  *    It is known to work with Sun/Oracle and Harmony JREs.
  *    If your application needs to be fully portable, consider using ICUTokenizer instead,
  *    which uses an ICU Thai BreakIterator that will always be available.
+ * <p><a name="version"/>As of Lucene 4.4 this filter never updates offsets
+ * and emits all tokens generated from the same input token at the same position.
  */
 public final class ThaiWordFilter extends TokenFilter {
   /** 
@@ -50,6 +53,8 @@
     proto.setText("ภาษาไทย");
     DBBI_AVAILABLE = proto.isBoundary(4);
   }
+
+  private final Version version;
   private final BreakIterator breaker = (BreakIterator) proto.clone();
   private final CharArrayIterator charIterator = CharArrayIterator.newWordInstance();
   
@@ -61,11 +66,12 @@
   private CharTermAttribute clonedTermAtt = null;
   private OffsetAttribute clonedOffsetAtt = null;
   private boolean hasMoreTokensInClone = false;
-  private boolean hasIllegalOffsets = false; // only if the length changed before this filter
+  private boolean updateOffsets = false; // never if the length changed before this filter
 
-  /** Creates a new ThaiWordFilter with the specified match version. */
+  /** Creates a new ThaiWordFilter with the specified <a href="#version">match version</a>. */
   public ThaiWordFilter(Version matchVersion, TokenStream input) {
     super(input);
+    this.version = matchVersion;
     if (!DBBI_AVAILABLE)
       throw new UnsupportedOperationException("This JRE does not have support for Thai segmentation");
   }
@@ -78,12 +84,14 @@
       if (end != BreakIterator.DONE) {
         clonedToken.copyTo(this);
         termAtt.copyBuffer(clonedTermAtt.buffer(), start, end - start);
-        if (hasIllegalOffsets) {
-          offsetAtt.setOffset(clonedOffsetAtt.startOffset(), clonedOffsetAtt.endOffset());
-        } else {
+        if (updateOffsets) {
           offsetAtt.setOffset(clonedOffsetAtt.startOffset() + start, clonedOffsetAtt.startOffset() + end);
         }
-        posAtt.setPositionIncrement(1);
+        if (version.onOrAfter(Version.LUCENE_44)) {
+          posAtt.setPositionIncrement(0);
+        } else {
+          posAtt.setPositionIncrement(1);
+        }
         return true;
       }
       hasMoreTokensInClone = false;
@@ -101,7 +109,11 @@
     
     // if length by start + end offsets doesn't match the term text then assume
     // this is a synonym and don't adjust the offsets.
-    hasIllegalOffsets = offsetAtt.endOffset() - offsetAtt.startOffset() != termAtt.length();
+    if (version.onOrAfter(Version.LUCENE_44)) {
+      updateOffsets = false;
+    } else {
+      updateOffsets = offsetAtt.endOffset() - offsetAtt.startOffset() == termAtt.length();
+    }
 
     // we lazy init the cloned token, as in ctor not all attributes may be added
     if (clonedToken == null) {
@@ -118,9 +130,7 @@
     int end = breaker.next();
     if (end != BreakIterator.DONE) {
       termAtt.setLength(end);
-      if (hasIllegalOffsets) {
-        offsetAtt.setOffset(clonedOffsetAtt.startOffset(), clonedOffsetAtt.endOffset());
-      } else {
+      if (updateOffsets) {
         offsetAtt.setOffset(clonedOffsetAtt.startOffset(), clonedOffsetAtt.startOffset() + end);
       }
       // position increment keeps as it is for first token
Index: lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java
===================================================================
--- lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java	(révision 1479915)
+++ lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java	(copie de travail)
@@ -179,8 +179,6 @@
           // TODO: it seems to mess up offsets!?
           WikipediaTokenizer.class,
           // TODO: doesn't handle graph inputs
-          ThaiWordFilter.class,
-          // TODO: doesn't handle graph inputs
           CJKBigramFilter.class,
           // TODO: doesn't handle graph inputs (or even look at positionIncrement)
           HyphenatedWordsFilter.class,
