Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed mapping of ZipException. Fixes some unit tests.

  • Loading branch information...
commit 7cd216578aa04458d21f31c81e89f4ae03e0822b 1 parent 4b1d9e7
@slluis slluis authored
View
4 NGit/NGit.Storage.File/ByteArrayWindow.cs
@@ -71,7 +71,7 @@ protected internal override int Copy(int p, byte[] b, int o, int n)
return n;
}
- /// <exception cref="Sharpen.DataFormatException"></exception>
+ /// <exception cref="ICSharpCode.SharpZipLib.SharpZipBaseException"></exception>
protected internal override int SetInput(int pos, Inflater inf)
{
int n = array.Length - pos;
@@ -96,7 +96,7 @@ internal void Crc32(CRC32 @out, long pos, int cnt)
}
}
- /// <exception cref="Sharpen.DataFormatException"></exception>
+ /// <exception cref="ICSharpCode.SharpZipLib.SharpZipBaseException"></exception>
internal void Check(Inflater inf, byte[] tmp, long pos, int cnt)
{
inf.SetInput(array, (int)(pos - start), cnt);
View
2  NGit/NGit.Storage.File/ByteBufferWindow.cs
@@ -94,7 +94,7 @@ protected internal override int Copy(int p, byte[] b, int o, int n)
}
}
- /// <exception cref="Sharpen.DataFormatException"></exception>
+ /// <exception cref="ICSharpCode.SharpZipLib.SharpZipBaseException"></exception>
protected internal override int SetInput(int pos, Inflater inf)
{
ByteBuffer s = buffer.Slice();
View
4 NGit/NGit.Storage.File/ByteWindow.cs
@@ -124,13 +124,13 @@ internal int Copy(long pos, byte[] dstbuf, int dstoff, int cnt)
internal abstract void Write(PackOutputStream @out, long pos, int cnt, MessageDigest
md);
- /// <exception cref="Sharpen.DataFormatException"></exception>
+ /// <exception cref="ICSharpCode.SharpZipLib.SharpZipBaseException"></exception>
internal int SetInput(long pos, Inflater inf)
{
return SetInput((int)(pos - start), inf);
}
- /// <exception cref="Sharpen.DataFormatException"></exception>
+ /// <exception cref="ICSharpCode.SharpZipLib.SharpZipBaseException"></exception>
protected internal abstract int SetInput(int pos, Inflater inf);
}
}
View
3  NGit/NGit.Storage.File/LargePackedDeltaObject.cs
@@ -42,6 +42,7 @@ written permission.
*/
using System.IO;
+using ICSharpCode.SharpZipLib;
using NGit;
using NGit.Errors;
using NGit.Storage.File;
@@ -126,7 +127,7 @@ public override long GetSize()
byte[] b = pack.GetDeltaHeader(wc, objectOffset + headerLength);
size = BinaryDelta.GetResultSize(b);
}
- catch (DataFormatException)
+ catch (SharpZipBaseException)
{
}
catch (IOException)
View
11 NGit/NGit.Storage.File/PackFile.cs
@@ -44,6 +44,7 @@ written permission.
using System;
using System.Collections.Generic;
using System.IO;
+using ICSharpCode.SharpZipLib;
using ICSharpCode.SharpZipLib.Zip.Compression;
using NGit;
using NGit.Errors;
@@ -308,7 +309,7 @@ internal virtual ObjectId FindObjectForOffset(long offset)
}
/// <exception cref="System.IO.IOException"></exception>
- /// <exception cref="Sharpen.DataFormatException"></exception>
+ /// <exception cref="ICSharpCode.SharpZipLib.SharpZipBaseException"></exception>
private byte[] Decompress(long position, int sz, WindowCursor curs)
{
byte[] dstbuf;
@@ -506,7 +507,7 @@ private byte[] Decompress(long position, int sz, WindowCursor curs)
}
}
}
- catch (DataFormatException dataFormat)
+ catch (SharpZipBaseException dataFormat)
{
SetCorrupt(src.offset);
CorruptObjectException corruptObject = new CorruptObjectException(MessageFormat.Format
@@ -971,7 +972,7 @@ internal virtual ObjectLoader Load(WindowCursor curs, long pos)
while (delta != null);
return new ObjectLoader.SmallObject(type, data);
}
- catch (DataFormatException dfe)
+ catch (SharpZipBaseException dfe)
{
CorruptObjectException coe = new CorruptObjectException(MessageFormat.Format(JGitText
.Get().objectAtHasBadZlibStream, pos, GetPackFile()));
@@ -1041,7 +1042,7 @@ private ObjectLoader NewLargeLoader(PackFile pack, WindowCursor wc)
}
/// <exception cref="System.IO.IOException"></exception>
- /// <exception cref="Sharpen.DataFormatException"></exception>
+ /// <exception cref="ICSharpCode.SharpZipLib.SharpZipBaseException"></exception>
internal virtual byte[] GetDeltaHeader(WindowCursor wc, long pos)
{
// The delta stream starts as two variable length integers. If we
@@ -1177,7 +1178,7 @@ internal virtual long GetObjectSize(WindowCursor curs, long pos)
{
return BinaryDelta.GetResultSize(GetDeltaHeader(curs, deltaAt));
}
- catch (DataFormatException)
+ catch (SharpZipBaseException)
{
throw new CorruptObjectException(MessageFormat.Format(JGitText.Get().objectAtHasBadZlibStream
, pos, GetPackFile()));
View
9 NGit/NGit.Storage.File/UnpackedObject.cs
@@ -42,6 +42,7 @@ written permission.
*/
using System.IO;
+using ICSharpCode.SharpZipLib;
using ICSharpCode.SharpZipLib.Zip.Compression;
using NGit;
using NGit.Errors;
@@ -183,7 +184,7 @@ public static ObjectLoader Parse(byte[] raw, AnyObjectId id)
return new UnpackedObject.LargeObject(type, size, path, id, wc.db);
}
}
- catch (ZipException)
+ catch (SharpZipBaseException)
{
throw new CorruptObjectException(id, JGitText.Get().corruptObjectBadStream);
}
@@ -233,7 +234,7 @@ internal static long GetSize(InputStream @in, AnyObjectId id, WindowCursor wc)
return size;
}
}
- catch (ZipException)
+ catch (SharpZipBaseException)
{
throw new CorruptObjectException(id, JGitText.Get().corruptObjectBadStream);
}
@@ -251,7 +252,7 @@ internal static long GetSize(InputStream @in, AnyObjectId id, WindowCursor wc)
{
r = inf.Inflate(buf);
}
- catch (DataFormatException)
+ catch (SharpZipBaseException)
{
throw new CorruptObjectException(id, JGitText.Get().corruptObjectBadStream);
}
@@ -323,7 +324,7 @@ public override int Read(byte[] b, int off, int cnt)
}
return r;
}
- catch (ZipException)
+ catch (SharpZipBaseException)
{
throw new CorruptObjectException(id, JGitText.Get().corruptObjectBadStream);
}
View
5 NGit/NGit.Storage.File/WindowCursor.cs
@@ -44,6 +44,7 @@ written permission.
using System;
using System.Collections.Generic;
using System.IO;
+using ICSharpCode.SharpZipLib;
using NGit;
using NGit.Errors;
using NGit.Revwalk;
@@ -283,7 +284,7 @@ public void CopyPackAsIs(PackOutputStream @out, CachedPack pack, bool validate)
/// this cursor does not match the provider or id and the proper
/// window could not be acquired through the provider's cache.
/// </exception>
- /// <exception cref="Sharpen.DataFormatException">
+ /// <exception cref="ICSharpCode.SharpZipLib.SharpZipBaseException">
/// the inflater encountered an invalid chunk of data. Data
/// stream corruption is likely.
/// </exception>
@@ -310,7 +311,7 @@ internal int Inflate(PackFile pack, long position, byte[] dstbuf, int dstoff)
}
else
{
- throw new DataFormatException();
+ throw new SharpZipBaseException();
}
}
}
View
3  NGit/NGit.Transport/PackParser.cs
@@ -44,6 +44,7 @@ written permission.
using System;
using System.Collections.Generic;
using System.IO;
+using ICSharpCode.SharpZipLib;
using ICSharpCode.SharpZipLib.Zip.Compression;
using NGit;
using NGit.Errors;
@@ -1782,7 +1783,7 @@ public override int Read(byte[] dst, int pos, int cnt)
this.actualSize += n;
return 0 < n ? n : -1;
}
- catch (DataFormatException dfe)
+ catch (SharpZipBaseException dfe)
{
throw new CorruptObjectException(MessageFormat.Format(JGitText.Get().packfileCorruptionDetected
, dfe.Message));
View
2  gen/sharpen-options.in
@@ -239,6 +239,8 @@
-typeMapping java.util.ArrayList<> Sharpen.AList
-typeMapping java.util.zip.Inflater ICSharpCode.SharpZipLib.Zip.Compression.Inflater
-typeMapping java.util.zip.Deflater ICSharpCode.SharpZipLib.Zip.Compression.Deflater
+-typeMapping java.util.zip.ZipException ICSharpCode.SharpZipLib.SharpZipBaseException
+-typeMapping java.util.zip.DataFormatException ICSharpCode.SharpZipLib.SharpZipBaseException
-typeMapping java.io.FileNotFoundException System.IO.FileNotFoundException
-typeMapping java.io.Reader System.IO.StreamReader
-typeMapping java.util.SortedSet<> System.Collections.Generic.ICollection

0 comments on commit 7cd2165

Please sign in to comment.
Something went wrong with that request. Please try again.