Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit c7783e5

Browse files
author
jofriedm-msft
authored
Merge pull request #88 from jofriedm-msft/dev
IOExceptions wrapping StorageExceptions will now contain the StorageE…
2 parents 4849bab + e15f006 commit c7783e5

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

ChangeLog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
2017.XX.XX Version 6.0.0
22
* Added support for taking a snapshot of a share.
3+
* IOExceptions wrapping StorageExceptions will now contain the StorageException message in the outer exception.
34

45
2017.08.28 Version 5.5.0
56
* Fixed a bug when using a SAS token where the token was being omitted from calls to delete a directory in the file service.

microsoft-azure-storage-test/src/com/microsoft/azure/storage/EventFiringTests.java

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@
2020
import com.microsoft.azure.storage.TestRunners.DevFabricTests;
2121
import com.microsoft.azure.storage.TestRunners.DevStoreTests;
2222

23-
import org.apache.http.protocol.HTTP;
2423
import org.junit.Test;
2524
import org.junit.experimental.categories.Category;
2625

27-
import java.io.ByteArrayInputStream;
28-
import java.io.IOException;
2926
import java.net.HttpURLConnection;
30-
import java.net.SocketException;
3127
import java.net.URISyntaxException;
3228
import java.util.ArrayList;
3329

@@ -121,39 +117,46 @@ public void eventOccurred(ErrorReceivingResponseEvent eventArg) {
121117
}
122118
});
123119

124-
OperationContext.getGlobalErrorReceivingResponseEventHandler().addListener(new StorageEvent<ErrorReceivingResponseEvent>() {
120+
StorageEvent<ErrorReceivingResponseEvent> globalResponseReceivedListener = new StorageEvent<ErrorReceivingResponseEvent>() {
125121

126122
@Override
127123
public void eventOccurred(ErrorReceivingResponseEvent eventArg) {
128124
fail("This event should not trigger");
129125
}
130-
});
126+
};
131127

132-
assertEquals(0, callList.size());
133-
assertEquals(0, globalCallList.size());
128+
try {
129+
OperationContext.getGlobalErrorReceivingResponseEventHandler().addListener(globalResponseReceivedListener);
134130

135-
CloudBlobClient blobClient = TestHelper.createCloudBlobClient();
136-
CloudBlobContainer container = blobClient.getContainerReference("container1");
131+
assertEquals(0, callList.size());
132+
assertEquals(0, globalCallList.size());
137133

138-
// make sure both update
139-
container.exists(null, null, eventContext);
140-
assertEquals(1, callList.size());
141-
assertEquals(1, globalCallList.size());
134+
CloudBlobClient blobClient = TestHelper.createCloudBlobClient();
135+
CloudBlobContainer container = blobClient.getContainerReference("container1");
142136

143-
// make sure only global updates
144-
container.exists();
145-
assertEquals(1, callList.size());
146-
assertEquals(2, globalCallList.size());
137+
// make sure both update
138+
container.exists(null, null, eventContext);
139+
assertEquals(1, callList.size());
140+
assertEquals(1, globalCallList.size());
147141

148-
OperationContext
149-
.setGlobalResponseReceivedEventHandler(new StorageEventMultiCaster<ResponseReceivedEvent, StorageEvent<ResponseReceivedEvent>>());
150-
eventContext
151-
.setResponseReceivedEventHandler(new StorageEventMultiCaster<ResponseReceivedEvent, StorageEvent<ResponseReceivedEvent>>());
142+
// make sure only global updates
143+
container.exists();
144+
assertEquals(1, callList.size());
145+
assertEquals(2, globalCallList.size());
152146

153-
// make sure neither update
154-
container.exists(null, null, eventContext);
155-
assertEquals(1, callList.size());
156-
assertEquals(2, globalCallList.size());
147+
OperationContext
148+
.setGlobalResponseReceivedEventHandler(new StorageEventMultiCaster<ResponseReceivedEvent, StorageEvent<ResponseReceivedEvent>>());
149+
eventContext
150+
.setResponseReceivedEventHandler(new StorageEventMultiCaster<ResponseReceivedEvent, StorageEvent<ResponseReceivedEvent>>());
151+
152+
// make sure neither update
153+
container.exists(null, null, eventContext);
154+
assertEquals(1, callList.size());
155+
assertEquals(2, globalCallList.size());
156+
}
157+
finally {
158+
OperationContext.getGlobalErrorReceivingResponseEventHandler().removeListener(globalResponseReceivedListener);
159+
}
157160
}
158161

159162
@Test

microsoft-azure-storage/src/com/microsoft/azure/storage/core/Utility.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,15 @@ public static XMLStreamWriter createXMLStreamWriter(StringWriter outWriter) thro
767767
* @return A <code>java.io.IOException</code> object that represents the created IO exception.
768768
*/
769769
public static IOException initIOException(final Exception ex) {
770-
final IOException retEx = new IOException();
771-
retEx.initCause(ex);
770+
String message = null;
771+
if (ex != null && ex.getMessage() != null) {
772+
message = ex.getMessage() + " Please see the cause for further information.";
773+
}
774+
else {
775+
message = "Please see the cause for further information.";
776+
}
777+
778+
final IOException retEx = new IOException(message, ex);
772779
return retEx;
773780
}
774781

0 commit comments

Comments
 (0)