|  | @@ -411,6 +411,25 @@ public class BytesStreamsTests extends ESTestCase {
 | 
	
		
			
				|  |  |          assertThat(e.getMessage(), endsWith("] returned null which is not allowed and probably means it screwed up the stream."));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    public void testWriteableReaderReturnsWrongName() throws IOException {
 | 
	
		
			
				|  |  | +        BytesStreamOutput out = new BytesStreamOutput();
 | 
	
		
			
				|  |  | +        NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
 | 
	
		
			
				|  |  | +        namedWriteableRegistry.register(BaseNamedWriteable.class, TestNamedWriteable.NAME, (StreamInput in) -> new TestNamedWriteable(in) {
 | 
	
		
			
				|  |  | +            @Override
 | 
	
		
			
				|  |  | +            public String getWriteableName() {
 | 
	
		
			
				|  |  | +                return "intentionally-broken";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        TestNamedWriteable namedWriteableIn = new TestNamedWriteable(randomAsciiOfLengthBetween(1, 10), randomAsciiOfLengthBetween(1, 10));
 | 
	
		
			
				|  |  | +        out.writeNamedWriteable(namedWriteableIn);
 | 
	
		
			
				|  |  | +        byte[] bytes = out.bytes().toBytes();
 | 
	
		
			
				|  |  | +        StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(bytes), namedWriteableRegistry);
 | 
	
		
			
				|  |  | +        assertEquals(in.available(), bytes.length);
 | 
	
		
			
				|  |  | +        AssertionError e = expectThrows(AssertionError.class, () -> in.readNamedWriteable(BaseNamedWriteable.class));
 | 
	
		
			
				|  |  | +        assertThat(e.getMessage(),
 | 
	
		
			
				|  |  | +                endsWith(" claims to have a different name [intentionally-broken] than it was read from [test-named-writeable]."));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      private static abstract class BaseNamedWriteable<T> implements NamedWriteable<T> {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 |