#vulnerable code 
                              @Test
  public void refreshAccessToken() throws IOException{
    final ServerSocket authSocket = new ServerSocket(0);
    Runnable serverTask = new Runnable() {
      @Override
      public void run() {
        try {
	  Socket clientSocket = authSocket.accept();
          BufferedReader input =
	    new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
	  String lines = input.readLine();
	  lines += '\n' + input.readLine();
          assertEquals(lines, CloudShellCredentials.GET_AUTH_TOKEN_REQUEST);

	  PrintWriter out =
	      new PrintWriter(clientSocket.getOutputStream(), true);
	  out.println("32\n[\"email\", \"project-id\", \"token\"]");
	} catch (Exception reThrown) {
	  throw new RuntimeException(reThrown);
	}
      }
    };
    Thread serverThread = new Thread(serverTask);
    serverThread.start();
    
    GoogleCredentials creds = new CloudShellCredentials(authSocket.getLocalPort());
    assertEquals("token", creds.refreshAccessToken().getTokenValue());
  } 
                            #location 26 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                              @Test
  public void refreshAccessToken() throws IOException{
    final ServerSocket authSocket = new ServerSocket(0);
    try {
      Runnable serverTask = new Runnable() {
        @Override
        public void run() {
          try {
            Socket clientSocket = authSocket.accept();
            BufferedReader input =
                new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
            String lines = input.readLine();
            lines += '\n' + input.readLine();
            assertEquals(lines, CloudShellCredentials.GET_AUTH_TOKEN_REQUEST);
  
            PrintWriter out =
                new PrintWriter(clientSocket.getOutputStream(), true);
            out.println("32\n[\"email\", \"project-id\", \"token\"]");
          } catch (Exception reThrown) {
            throw new RuntimeException(reThrown);
          }
        }
      };
      Thread serverThread = new Thread(serverTask);
      serverThread.start();
      
      GoogleCredentials creds = new CloudShellCredentials(authSocket.getLocalPort());
      assertEquals("token", creds.refreshAccessToken().getTokenValue());
    } finally {
      authSocket.close();
    }
  }