Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions eng/jacoco-test-coverage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<azure-identity.version>1.0.0-preview.3</azure-identity.version>
<azure-keyvault.version>4.0.0-preview.3</azure-keyvault.version>
<azure-messaging-eventhubs.version>5.0.0-preview.3</azure-messaging-eventhubs.version>
<azure-storage-common.version>12.0.0-preview.3</azure-storage-common.version>
<azure-storage-blob.version>12.0.0-preview.3</azure-storage-blob.version>
<azure-storage-file.version>12.0.0-preview.3</azure-storage-file.version>
<azure-storage-queue.version>12.0.0-preview.3</azure-storage-queue.version>
Expand Down Expand Up @@ -96,6 +97,11 @@
<artifactId>azure-messaging-eventhubs</artifactId>
<version>${azure-messaging-eventhubs.version}</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-common</artifactId>
<version>${azure-storage-common.version}</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
Expand Down
19 changes: 13 additions & 6 deletions eng/spotbugs-aggregate-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<azure-identity.version>1.0.0-preview.3</azure-identity.version>
<azure-keyvault.version>4.0.0-preview.3</azure-keyvault.version>
<azure-messaging-eventhubs.version>5.0.0-preview.3</azure-messaging-eventhubs.version>
<azure-storage-common.version>12.0.0-preview.3</azure-storage-common.version>
<azure-storage-blob.version>12.0.0-preview.3</azure-storage-blob.version>
<azure-storage-file.version>12.0.0-preview.3</azure-storage-file.version>
<azure-storage-queue.version>12.0.0-preview.3</azure-storage-queue.version>
Expand Down Expand Up @@ -68,12 +69,13 @@
<!-- <source>..\..\sdk\keyvault\azure-keyvault-keys\src\samples\java</source>-->
<!-- <source>..\..\sdk\keyvault\azure-keyvault-secrets\src\main\java</source>-->
<!-- <source>..\..\sdk\keyvault\azure-keyvault-secrets\src\samples\java</source>-->
<!-- <source>..\..\sdk\storage\client\blob\src\main\java</source>-->
<!-- <source>..\..\sdk\storage\client\blob\src\samples\java</source>-->
<!-- <source>..\..\sdk\storage\client\files\src\main\java</source>-->
<!-- <source>..\..\sdk\storage\client\files\src\samples\java</source>-->
<!-- <source>..\..\sdk\storage\client\queues\src\main\java</source>-->
<!-- <source>..\..\sdk\storage\client\queues\src\samples\java</source>-->
<source>..\..\sdk\storage\azure-storage-common\src\main\java</source>
<source>..\..\sdk\storage\azure-storage-blob\src\main\java</source>
<source>..\..\sdk\storage\azure-storage-blob\src\samples\java</source>
<source>..\..\sdk\storage\azure-storage-file\src\main\java</source>
<source>..\..\sdk\storage\azure-storage-file\src\samples\java</source>
<source>..\..\sdk\storage\azure-storage-queue\src\main\java</source>
<source>..\..\sdk\storage\azure-storage-queue\src\samples\java</source>
<!-- <source>..\..\sdk\tracing\azure-tracing-opentelemetry\src\main\java</source>-->
</sources>
</configuration>
Expand Down Expand Up @@ -185,6 +187,11 @@
<artifactId>azure-keyvault-secrets</artifactId>
<version>${azure-keyvault.version}</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-common</artifactId>
<version>${azure-storage-common.version}</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Locale;

/**
Expand Down Expand Up @@ -72,7 +72,7 @@ public static void main(String[] args) throws IOException {
BlockBlobClient blobClient = containerClient.getBlockBlobClient("HelloWorld.txt");

String data = "Hello world!";
InputStream dataStream = new ByteArrayInputStream(data.getBytes());
InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));

/*
* Create the blob with string (plain text) content.
Expand All @@ -85,14 +85,14 @@ public static void main(String[] args) throws IOException {
* Download the blob's content to output stream.
*/
int dataSize = (int) blobClient.getProperties().blobSize();
OutputStream outputStream = new ByteArrayOutputStream(dataSize);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(dataSize);
blobClient.download(outputStream);
outputStream.close();

/*
* Verify that the blob data round-tripped correctly.
*/
if (!data.equals(outputStream.toString())) {
if (!data.equals(new String(outputStream.toByteArray(), StandardCharsets.UTF_8))) {
throw new RuntimeException("The downloaded data does not match the uploaded data.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.azure.storage.blob.models.ModifiedAccessConditions;
import com.azure.storage.blob.models.ReliableDownloadOptions;
import com.azure.storage.blob.models.StorageAccountInfo;
import com.azure.storage.common.Constants;

import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -63,7 +64,7 @@ public void startCopyFromURL() {
public void abortCopyFromURL() {
// BEGIN: com.azure.storage.blob.BlobClient.abortCopyFromURL#String
client.abortCopyFromURL(copyId);
System.out.printf("Aborted copy completed.");
System.out.println("Aborted copy completed.");
// END: com.azure.storage.blob.BlobClient.abortCopyFromURL#String
}

Expand All @@ -82,7 +83,7 @@ public void copyFromURL() {
public void download() {
// BEGIN: com.azure.storage.blob.BlobClient.download#OutputStream
client.download(new ByteArrayOutputStream());
System.out.printf("Download completed.");
System.out.println("Download completed.");
// END: com.azure.storage.blob.BlobClient.download#OutputStream
}

Expand All @@ -100,7 +101,7 @@ public void downloadToFile() {
BlobRange range = new BlobRange(1024, 2048L);
ReliableDownloadOptions options = new ReliableDownloadOptions().maxRetryRequests(5);

client.downloadToFile(file, range, null, options, null, false, timeout, new Context(key2, value2));
client.downloadToFile(file, range, 4 * Constants.MB, options, null, false, timeout, new Context(key2, value2));
System.out.println("Completed download to file");
// END: com.azure.storage.blob.BlobClient.downloadToFile#String-BlobRange-Integer-ReliableDownloadOptions-BlobAccessConditions-boolean-Duration-Context
}
Expand All @@ -111,7 +112,7 @@ public void downloadToFile() {
public void delete() {
// BEGIN: com.azure.storage.blob.BlobClient.delete
client.delete();
System.out.printf("Delete completed.");
System.out.println("Delete completed.");
// END: com.azure.storage.blob.BlobClient.delete
}

Expand All @@ -133,7 +134,7 @@ public void setHTTPHeaders() {
client.setHTTPHeaders(new BlobHTTPHeaders()
.blobContentLanguage("en-US")
.blobContentType("binary"));
System.out.printf("Set HTTP headers completed");
System.out.println("Set HTTP headers completed");
// END: com.azure.storage.blob.BlobClient.setHTTPHeaders#BlobHTTPHeaders
}

Expand All @@ -143,7 +144,7 @@ public void setHTTPHeaders() {
public void setMetadata() {
// BEGIN: com.azure.storage.blob.BlobClient.setMetadata#Metadata
client.setMetadata(new Metadata(Collections.singletonMap("metadata", "value")));
System.out.printf("Set metadata completed");
System.out.println("Set metadata completed");
// END: com.azure.storage.blob.BlobClient.setMetadata#Metadata
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
Expand Down Expand Up @@ -121,16 +121,17 @@ public static void main(String[] args) throws IOException, NoSuchAlgorithmExcept
}

private static File createTempEmptyFile(String fileName) throws IOException {
URL folderUrl = FileTransferExample.class.getClassLoader().getResource(".");
String pathName = "./folderPath/" + LARGE_TEST_FOLDER;

File dirPath = new File(folderUrl.getPath() + LARGE_TEST_FOLDER);
File dirPath = new File(pathName);

if (dirPath.exists() || dirPath.mkdir()) {
File f = new File(folderUrl.getPath() + LARGE_TEST_FOLDER + fileName);
if (!f.exists()) {
f.createNewFile();
File f = new File(pathName + fileName);
if (f.exists() || f.createNewFile()) {
return f;
} else {
throw new RuntimeException("Failed to create the large file.");
}
return f;
} else {
throw new RuntimeException("Failed to create the large file dir.");
}
Expand Down Expand Up @@ -164,9 +165,8 @@ private static String getFileChecksum(File file) throws IOException, NoSuchAlgor
buf.clear();
b = ch.read(buf);
}
ch.close();
fis.close();
return new String(md.digest());

return new String(md.digest(), StandardCharsets.UTF_8);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Locale;

Expand Down Expand Up @@ -77,7 +78,7 @@ public static void main(String[] args) throws IOException {
* Data which will upload to block blob.
*/
String data = "Hello world!";
InputStream dataStream = new ByteArrayInputStream(data.getBytes());
InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
blobClient.uploadWithResponse(dataStream, data.length(), blobHTTPHeaders, blobMetadata, null, null, null);

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,9 @@ public ShareClientBuilder shareName(String shareName) {
*
* @param snapshot Identifier of the snapshot
* @return the updated ShareClientBuilder object
* @throws NullPointerException If {@code snapshot} is {@code null}.
*/
public ShareClientBuilder snapshot(String snapshot) {
this.snapshot = Objects.requireNonNull(snapshot);
this.snapshot = snapshot;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public void setMetadataAsync() {
DirectoryAsyncClient directoryAsyncClient = createAsyncClientWithSASToken();
// BEGIN: com.azure.storage.file.directoryAsyncClient.setMetadata#map
directoryAsyncClient.setMetadata(Collections.singletonMap("directory", "updatedMetadata"))
.subscribe(response -> System.out.printf("Setting the directory metadata completed."));
.subscribe(response -> System.out.println("Setting the directory metadata completed."));
// END: com.azure.storage.file.directoryAsyncClient.setMetadata#map
}

Expand All @@ -316,7 +316,7 @@ public void setMetadataClear() {
DirectoryAsyncClient directoryAsyncClient = createAsyncClientWithSASToken();
// BEGIN: com.azure.storage.file.directoryAsyncClient.setMetadata#map.clearMetadata
directoryAsyncClient.setMetadata(null)
.doOnSuccess(response -> System.out.printf("Clearing the directory metadata compleetd"));
.doOnSuccess(response -> System.out.println("Clearing the directory metadata completed"));
// END: com.azure.storage.file.directoryAsyncClient.setMetadata#map.clearMetadata
}

Expand All @@ -339,7 +339,7 @@ public void setMetadataWithResponse() {
DirectoryAsyncClient directoryAsyncClient = createAsyncClientWithSASToken();
// BEGIN: com.azure.storage.file.directoryAsyncClient.setMetadataWithResponse#map
directoryAsyncClient.setMetadataWithResponse(Collections.singletonMap("directory", "updatedMetadata"))
.subscribe(response -> System.out.printf("Setting the directory metadata completed with status code:"
.subscribe(response -> System.out.println("Setting the directory metadata completed with status code:"
+ response.statusCode()));
// END: com.azure.storage.file.directoryAsyncClient.setMetadataWithResponse#map
}
Expand All @@ -363,11 +363,8 @@ public void forceCloseHandlesAsync() {
DirectoryAsyncClient directoryAsyncClient = createAsyncClientWithSASToken();
// BEGIN: com.azure.storage.file.directoryAsyncClient.forceCloseHandles
directoryAsyncClient.listHandles(10, true)
.subscribe(handleItem -> {
directoryAsyncClient.forceCloseHandles(handleItem.handleId(), true)
.subscribe(numOfClosedHandles ->
System.out.printf("Close %d handles.", numOfClosedHandles));
});
.subscribe(handleItem -> directoryAsyncClient.forceCloseHandles(handleItem.handleId(), true)
.subscribe(numOfClosedHandles -> System.out.printf("Closed %d handles.", numOfClosedHandles)));
// END: com.azure.storage.file.directoryAsyncClient.forceCloseHandles
}

Expand All @@ -384,7 +381,8 @@ public void getShareSnapshotIdAsync() {
.directoryPath("mydirectory")
.snapshot(currentTime.toString())
.buildAsyncClient();
directoryAsyncClient.getShareSnapshotId();

System.out.printf("Snapshot ID: %s%n", directoryAsyncClient.getShareSnapshotId());
// END: com.azure.storage.file.directoryAsyncClient.getShareSnapshotId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ public void getShareSnapshotId() {
.directoryPath("mydirectory")
.snapshot(currentTime.toString())
.buildClient();
directoryClient.getShareSnapshotId();

System.out.printf("Snapshot ID: %s%n", directoryClient.getShareSnapshotId());
// END: com.azure.storage.file.directoryClient.getShareSnapshotId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ public static void main(String[] args) {
}

// Create a 1KB file under the child directory.
DirectoryClient childDirClient = null;
DirectoryClient childDirClient = directoryClient.getSubDirectoryClient(childDirectoryName);
String fileName = generateRandomName();
try {
childDirClient = directoryClient.getSubDirectoryClient(childDirectoryName);
childDirClient.createFile(fileName, 1024);
} catch (StorageErrorException e) {
System.out.println("Failed to create a file under the child directory. Reasons: " + e.getMessage());
Expand All @@ -67,19 +66,16 @@ public static void main(String[] args) {
// List all the sub directories and files.
try {
directoryClient.listFilesAndDirectories().forEach(
fileRef -> {
System.out.printf("Is the resource a directory? %b. The resource name is: ", fileRef.isDirectory(),
fileRef.name());
}
);
fileRef -> System.out.printf("Is the resource a directory? %b. The resource name is: %s%n",
fileRef.isDirectory(), fileRef.name()));
} catch (StorageErrorException e) {
System.out.println("Failed to list all the subdirectories and files. Reasons: " + e.getMessage());
}

// Get the parent directory properties.
try {
DirectoryProperties propertiesResponse = directoryClient.getProperties();
System.out.printf("This is the eTag %s of the directory: ", propertiesResponse.eTag());
System.out.printf("This is the eTag of the directory: %s%n", propertiesResponse.eTag());
} catch (StorageErrorException e) {
System.out.println("Failed to get the properties of the parent directory");
}
Expand Down
Loading