@ -1017,27 +1017,23 @@ public class UploadPack {
if ( ! err . isOutput ( ) & & err . getMessage ( ) ! = null ) {
if ( ! err . isOutput ( ) & & err . getMessage ( ) ! = null ) {
try {
try {
pckOut . writeString ( "ERR " + err . getMessage ( ) + "\n" ) ; //$NON-NLS-1$ //$NON-NLS-2$
pckOut . writeString ( "ERR " + err . getMessage ( ) + "\n" ) ; //$NON-NLS-1$ //$NON-NLS-2$
err . setOutput ( ) ;
} catch ( IOException e ) {
} catch ( Throwable err2 ) {
err . addSuppressed ( e ) ;
// Ignore this secondary failure (and not mark output).
throw err ;
}
}
err . setOutput ( ) ;
}
}
throw err ;
throw err ;
} catch ( IOException | RuntimeException | Error err ) {
} catch ( IOException | RuntimeException | Error err ) {
boolean output = false ;
String msg = err instanceof PackProtocolException ? err . getMessage ( )
try {
String msg = err instanceof PackProtocolException
? err . getMessage ( )
: JGitText . get ( ) . internalServerError ;
: JGitText . get ( ) . internalServerError ;
try {
pckOut . writeString ( "ERR " + msg + "\n" ) ; //$NON-NLS-1$ //$NON-NLS-2$
pckOut . writeString ( "ERR " + msg + "\n" ) ; //$NON-NLS-1$ //$NON-NLS-2$
output = true ;
} catch ( IOException e ) {
} catch ( Throwable err2 ) {
err . addSuppressed ( e ) ;
// Ignore this secondary failure, leave output false.
throw err ;
}
}
if ( output ) {
throw new UploadPackInternalServerErrorException ( err ) ;
throw new UploadPackInternalServerErrorException ( err ) ;
}
throw err ;
} finally {
} finally {
if ( ! sendPack & & ! biDirectionalPipe ) {
if ( ! sendPack & & ! biDirectionalPipe ) {
while ( 0 < rawIn . skip ( 2048 ) | | 0 < = rawIn . read ( ) ) {
while ( 0 < rawIn . skip ( 2048 ) | | 0 < = rawIn . read ( ) ) {
@ -2077,31 +2073,26 @@ public class UploadPack {
// This was already reported on (below).
// This was already reported on (below).
throw noPack ;
throw noPack ;
} catch ( IOException | RuntimeException | Error err ) {
} catch ( IOException | RuntimeException | Error err ) {
if ( reportInternalServerErrorOverSideband ( ) ) {
try {
throw new UploadPackInternalServerErrorException ( err ) ;
reportInternalServerErrorOverSideband ( ) ;
} else {
} catch ( IOException e ) {
err . addSuppressed ( e ) ;
throw err ;
throw err ;
}
}
throw new UploadPackInternalServerErrorException ( err ) ;
}
}
} else {
} else {
sendPack ( false , req , accumulator , allTags , unshallowCommits , deepenNots ) ;
sendPack ( false , req , accumulator , allTags , unshallowCommits , deepenNots ) ;
}
}
}
}
private boolean reportInternalServerErrorOverSideband ( ) {
private void reportInternalServerErrorOverSideband ( ) throws IOException {
try {
@SuppressWarnings ( "resource" /* java 7 */ )
@SuppressWarnings ( "resource" /* java 7 */ )
SideBandOutputStream err = new SideBandOutputStream (
SideBandOutputStream err = new SideBandOutputStream (
SideBandOutputStream . CH_ERROR ,
SideBandOutputStream . CH_ERROR , SideBandOutputStream . SMALL_BUF ,
SideBandOutputStream . SMALL_BUF ,
rawOut ) ;
rawOut ) ;
err . write ( Constants . encode ( JGitText . get ( ) . internalServerError ) ) ;
err . write ( Constants . encode ( JGitText . get ( ) . internalServerError ) ) ;
err . flush ( ) ;
err . flush ( ) ;
return true ;
} catch ( Throwable cannotReport ) {
// Ignore the reason. This is a secondary failure.
return false ;
}
}
}
/ * *
/ * *