#fixed code
                             @Test
	public void testWindowUpdate() throws Throwable {
		MockSession clientSession = new MockSession();
		MockSession serverSession = new MockSession();
		
		SpdySessionAttachment clientAttachment = new SpdySessionAttachment(new Connection(clientSession, true));
		SpdySessionAttachment serverAttachment = new SpdySessionAttachment(new Connection(serverSession, false));
		
		clientSession.attachObject(clientAttachment);
		serverSession.attachObject(serverAttachment);
		
		SpdyDecoder clientDecoder = new SpdyDecoder(new DefaultSpdyDecodingEventListener(new StreamEventListener(){

			@Override
			public void onSynStream(SynStreamFrame synStreamFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onSynReply(SynReplyFrame synReplyFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onRstStream(RstStreamFrame rstStreamFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onHeaders(HeadersFrame headersFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onData(DataFrame dataFrame, Stream stream, Connection connection) {

			}}, new SettingsManager(null, "localhost", 7777)));
		
		SpdyDecoder serverDecoder = new SpdyDecoder(new DefaultSpdyDecodingEventListener(new StreamEventListener(){

			@Override
			public void onSynStream(SynStreamFrame synStreamFrame, Stream stream, Connection connection) {
				System.out.println("Server receives syn stream -> " + synStreamFrame);
				
			}

			@Override
			public void onSynReply(SynReplyFrame synReplyFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onRstStream(RstStreamFrame rstStreamFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onHeaders(HeadersFrame headersFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onData(DataFrame dataFrame, Stream stream, Connection connection) {
				System.out.println("Server receives data -> " + dataFrame);
				if(dataFrame.getFlags() == DataFrame.FLAG_FIN) {
					Fields headers = stream.createFields();
					headers.put("response", "ok");
					stream.reply(Version.V3, (byte)0, headers);
					stream.sendLastData("the server has received messages".getBytes());
				}
			}}, null));
		
		// Client creates a stream
		Stream clientStream = clientAttachment.getConnection().createStream(new StreamEventListener(){

			@Override
			public void onSynStream(SynStreamFrame synStreamFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onSynReply(SynReplyFrame synReplyFrame, Stream stream, Connection connection) {
				System.out.println("Client receives reply frame -> " + synReplyFrame);
				Assert.assertThat(synReplyFrame.getHeaders().get("response").getValue(), is("ok"));
			}

			@Override
			public void onRstStream(RstStreamFrame rstStreamFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onHeaders(HeadersFrame headersFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onData(DataFrame dataFrame, Stream stream, Connection connection) {
				System.out.println("Client receives data -> " + dataFrame);
				if(dataFrame.getFlags() == DataFrame.FLAG_FIN) {
					Assert.assertThat(new String(dataFrame.getData()), is("the server has received messages"));
				}
			}});
		
		Assert.assertThat(clientStream.getId(), is(1));
		Assert.assertThat(clientStream.getPriority(), is((byte)0));
		Assert.assertThat(clientAttachment.getConnection().getStream(1) == clientStream, is(true));
		
		// Client sends a SYN stream to server
		Fields headers = clientStream.createFields();
		headers.put("test1", "testValue1");
		headers.put("test2", "testValue2");
		headers.add("testM1", "testm1");
		headers.add("testM2", "testm2");
		clientStream.syn(Version.V3, (byte)0, 0, (byte)0, headers);
		Assert.assertThat(clientStream.getWindowSize(), is(64 * 1024));
		Assert.assertThat(clientAttachment.getConnection().getWindowSize(), is(64 * 1024));
		
		// Server receives a SYN stream
		serverDecoder.decode(clientSession.outboundData.poll(), serverSession);
		
		// Client sends data frames
		int currentWindowSize = 64 * 1024;
		byte[] data = "hello world".getBytes();
		clientStream.sendData(data);
		currentWindowSize -= data.length;
		Assert.assertThat(clientStream.getWindowSize(), is(currentWindowSize));
		Assert.assertThat(clientAttachment.getConnection().getWindowSize(), is(currentWindowSize));

		data = "data2".getBytes();
		clientStream.sendData(data);
		currentWindowSize -= data.length;
		Assert.assertThat(clientStream.getWindowSize(), is(currentWindowSize));
		Assert.assertThat(clientAttachment.getConnection().getWindowSize(), is(currentWindowSize));
		
		data = "data3".getBytes();
		clientStream.sendLastData(data);
		currentWindowSize -= data.length;
		Assert.assertThat(clientStream.getWindowSize(), is(currentWindowSize));
		Assert.assertThat(clientAttachment.getConnection().getWindowSize(), is(currentWindowSize));
		Assert.assertThat(clientStream.isOutboundClosed(), is(true));
		Assert.assertThat(clientStream.isInboundClosed(), is(false));
		
		// Server receives data
		ByteBuffer buf = null;
		while( (buf = clientSession.outboundData.poll()) != null ) {
			serverDecoder.decode(buf, serverSession);
		}
		
		// Server sends window update and replies
		while( (buf = serverSession.outboundData.poll()) != null ) {
			clientDecoder.decode(buf, clientSession);
		}
		Assert.assertThat(clientStream.isOutboundClosed(), is(true));
		Assert.assertThat(clientStream.isInboundClosed(), is(true));
		Assert.assertThat(clientAttachment.getConnection().getWindowSize(), is(64 * 1024));
	}
#vulnerable code 
                             @Test
	public void testWindowUpdate() throws Throwable {
		MockSession clientSession = new MockSession();
		MockSession serverSession = new MockSession();
		
		SpdySessionAttachment clientAttachment = new SpdySessionAttachment(new Connection(clientSession, true));
		SpdySessionAttachment serverAttachment = new SpdySessionAttachment(new Connection(serverSession, false));
		
		clientSession.attachObject(clientAttachment);
		serverSession.attachObject(serverAttachment);
		
		SpdyDecoder clientDecoder = new SpdyDecoder(new DefaultSpdyDecodingEventListener(new StreamEventListener(){

			@Override
			public void onSynStream(SynStreamFrame synStreamFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onSynReply(SynReplyFrame synReplyFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onRstStream(RstStreamFrame rstStreamFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onHeaders(HeadersFrame headersFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onData(DataFrame dataFrame, Stream stream, Connection connection) {

			}}, new SettingsManager(null, "localhost", 7777)));
		
		SpdyDecoder serverDecoder = new SpdyDecoder(new DefaultSpdyDecodingEventListener(new StreamEventListener(){

			@Override
			public void onSynStream(SynStreamFrame synStreamFrame, Stream stream, Connection connection) {
				System.out.println("Server receives syn stream -> " + synStreamFrame);
				
			}

			@Override
			public void onSynReply(SynReplyFrame synReplyFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onRstStream(RstStreamFrame rstStreamFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onHeaders(HeadersFrame headersFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onData(DataFrame dataFrame, Stream stream, Connection connection) {

			}}, null));
		
		// Client creates a stream
		Stream clientStream = clientAttachment.getConnection().createStream(new StreamEventListener(){

			@Override
			public void onSynStream(SynStreamFrame synStreamFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onSynReply(SynReplyFrame synReplyFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onRstStream(RstStreamFrame rstStreamFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onHeaders(HeadersFrame headersFrame, Stream stream, Connection connection) {

			}

			@Override
			public void onData(DataFrame dataFrame, Stream stream, Connection connection) {

			}});
		
		Assert.assertThat(clientStream.getId(), is(1));
		Assert.assertThat(clientStream.getPriority(), is((byte)0));
		Assert.assertThat(clientAttachment.getConnection().getStream(1) == clientStream, is(true));
		
		// Client sends a SYN stream to server
		Fields headers = clientStream.createFields();
		headers.put("test1", "testValue1");
		headers.put("test2", "testValue2");
		headers.add("testM1", "testm1");
		headers.add("testM2", "testm2");
		clientStream.syn((short)3, (byte)0, 0, (byte)0, headers);
		Assert.assertThat(clientStream.getWindowSize(), is(64 * 1024));
		Assert.assertThat(clientAttachment.getConnection().getWindowSize(), is(64 * 1024));
		
		// Server receives a SYN stream
		serverDecoder.decode(clientSession.outboundData.poll(), serverSession);
		
		
		
		int currentWindowSize = 64 * 1024;
		byte[] data = "hello world".getBytes();
		clientStream.sendData(data);
		currentWindowSize -= data.length;
		Assert.assertThat(clientStream.getWindowSize(), is(currentWindowSize));
		Assert.assertThat(clientAttachment.getConnection().getWindowSize(), is(currentWindowSize));
		

		data = "data2".getBytes();
		clientStream.sendData(data);
		currentWindowSize -= data.length;
		Assert.assertThat(clientStream.getWindowSize(), is(currentWindowSize));
		Assert.assertThat(clientAttachment.getConnection().getWindowSize(), is(currentWindowSize));
	} 
                            #location 110 
                            #vulnerability type RESOURCE_LEAK