@ -44,6 +44,8 @@
package org.eclipse.jgit.transport ;
package org.eclipse.jgit.transport ;
import static org.eclipse.jgit.transport.SideBandOutputStream.HDR_SIZE ;
import java.io.IOException ;
import java.io.IOException ;
import java.io.InputStream ;
import java.io.InputStream ;
import java.util.regex.Matcher ;
import java.util.regex.Matcher ;
@ -69,7 +71,7 @@ import org.eclipse.jgit.util.RawParseUtils;
* Channel 3 results in an exception being thrown , as the remote side has issued
* Channel 3 results in an exception being thrown , as the remote side has issued
* an unrecoverable error .
* an unrecoverable error .
*
*
* @see PacketLineIn # sideband ( ProgressMonitor )
* @see SideBandOutputStream
* /
* /
class SideBandInputStream extends InputStream {
class SideBandInputStream extends InputStream {
static final int CH_DATA = 1 ;
static final int CH_DATA = 1 ;
@ -84,9 +86,9 @@ class SideBandInputStream extends InputStream {
private static Pattern P_BOUNDED = Pattern . compile (
private static Pattern P_BOUNDED = Pattern . compile (
"^([\\w ]+):.*\\((\\d+)/(\\d+)\\).*" , Pattern . DOTALL ) ;
"^([\\w ]+):.*\\((\\d+)/(\\d+)\\).*" , Pattern . DOTALL ) ;
private final PacketLineIn pck In;
private final InputStream raw In;
private final InputStream i n;
private final PacketLineIn pckI n;
private final ProgressMonitor monitor ;
private final ProgressMonitor monitor ;
@ -102,11 +104,10 @@ class SideBandInputStream extends InputStream {
private int available ;
private int available ;
SideBandInputStream ( final PacketLineIn aPckIn , final InputStream aIn ,
SideBandInputStream ( final InputStream in , final ProgressMonitor progress ) {
final ProgressMonitor aProgress ) {
rawIn = in ;
pckIn = aPckIn ;
pckIn = new PacketLineIn ( rawIn ) ;
in = aIn ;
monitor = progress ;
monitor = aProgress ;
currentTask = "" ;
currentTask = "" ;
}
}
@ -116,7 +117,7 @@ class SideBandInputStream extends InputStream {
if ( eof )
if ( eof )
return - 1 ;
return - 1 ;
available - - ;
available - - ;
return i n. read ( ) ;
return rawI n. read ( ) ;
}
}
@Override
@Override
@ -126,7 +127,7 @@ class SideBandInputStream extends InputStream {
needDataPacket ( ) ;
needDataPacket ( ) ;
if ( eof )
if ( eof )
break ;
break ;
final int n = i n. read ( b , off , Math . min ( len , available ) ) ;
final int n = rawI n. read ( b , off , Math . min ( len , available ) ) ;
if ( n < 0 )
if ( n < 0 )
break ;
break ;
r + = n ;
r + = n ;
@ -147,8 +148,8 @@ class SideBandInputStream extends InputStream {
return ;
return ;
}
}
channel = i n. read ( ) ;
channel = rawI n. read ( ) ;
available - = 5 ; // length header plus channel indicator
available - = HDR_SIZE ; // length header plus channel indicator
if ( available = = 0 )
if ( available = = 0 )
continue ;
continue ;
@ -157,7 +158,6 @@ class SideBandInputStream extends InputStream {
return ;
return ;
case CH_PROGRESS :
case CH_PROGRESS :
progress ( readString ( available ) ) ;
progress ( readString ( available ) ) ;
continue ;
continue ;
case CH_ERROR :
case CH_ERROR :
eof = true ;
eof = true ;
@ -229,7 +229,7 @@ class SideBandInputStream extends InputStream {
private String readString ( final int len ) throws IOException {
private String readString ( final int len ) throws IOException {
final byte [ ] raw = new byte [ len ] ;
final byte [ ] raw = new byte [ len ] ;
IO . readFully ( i n, raw , 0 , len ) ;
IO . readFully ( rawI n, raw , 0 , len ) ;
return RawParseUtils . decode ( Constants . CHARSET , raw , 0 , len ) ;
return RawParseUtils . decode ( Constants . CHARSET , raw , 0 , len ) ;
}
}
}
}