code: private void closeNetworkResources() {
  		for (ResultPartition partition : producedPartitions) {
  			try {
  				partition.close();
  			} catch (Throwable t) {
  				ExceptionUtils.rethrowIfFatalError(t);
  				LOG.error("Failed to release result partition for task {}.", taskNameWithSubtask, t);
  			}
  		}
  
  		for (InputGate inputGate : inputGates) {
  			try {
  				inputGate.close();
  			} catch (Throwable t) {
  				ExceptionUtils.rethrowIfFatalError(t);
  				LOG.error("Failed to release input gate for task {}.", taskNameWithSubtask, t);
  			}
  		}
  	}
docs: There are two scenarios to close the network resources. One is from {@link TaskCanceler} to early
  release partitions and gates. Another is from task thread during task exiting.