Giter Site home page Giter Site logo

[BUG] Android java - azure-storage-blob - blobClient.getProperties().getLastModified() - Wrong number of arguments; expected 1, got 0 about azure-sdk-for-java HOT 2 OPEN

ARJEnkotec avatar ARJEnkotec commented on June 16, 2024
[BUG] Android java - azure-storage-blob - blobClient.getProperties().getLastModified() - Wrong number of arguments; expected 1, got 0

from azure-sdk-for-java.

Comments (2)

joshfree avatar joshfree commented on June 16, 2024

@ibrahimrabab could you please follow up with @ARJEnkotec;

/cc @alzimmermsft

from azure-sdk-for-java.

ARJEnkotec avatar ARJEnkotec commented on June 16, 2024

I have worked a bit on it and have made a different project, to show what it can and can't do. I found that the .listBlobs for loop never returns anything or exits even though there are blobs in the container.

I can succesfully download a blob client item, but if i try to get the last modified parameter of that blob client i get an error: "Wrong number of arguments; expected 1, got 0".

package com.example.azureblobstoragepropertiestest;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;

import com.azure.storage.blob.BlobServiceClientBuilder;
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.models.BlobItem;
import com.azure.storage.blob.BlobClient;

import java.time.OffsetDateTime;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;

public class MainActivity extends Activity {

    private static final String connectStr = "XXXXX";
    private static final String containerName = "XXXXX";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        BlobContainerClient containerClient = new BlobServiceClientBuilder()
                .connectionString(connectStr)
                .buildClient()
                .getBlobContainerClient(containerName);

        try {
            String downloadFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath();

            BlobClient blobClientDownload = containerClient.getBlobClient("blobtest.txt");

            String filePath = downloadFolder + "/" + blobClientDownload.getBlobName();

            blobClientDownload.downloadToFile(filePath, true);
            System.out.println("Azure blob file downloaded successfully!");

            String fileContent = new String(Files.readAllBytes(Paths.get(filePath)), StandardCharsets.UTF_8);
            System.out.println("File Content:\n" + fileContent);

            try {
                OffsetDateTime lastModifiedDownload = blobClientDownload.getProperties().getLastModified();
                System.out.println("Last modified date downloaded blob: " + lastModifiedDownload);
            } catch (Exception e) {
                System.err.println("Get last modified of downloaded blob error: " + e.getMessage());
            }

            System.out.println("Blobs in the container:");
                for (BlobItem blobItem : containerClient.listBlobs()) {
                    BlobClient blobClient = containerClient.getBlobClient(blobItem.getName());
                    OffsetDateTime lastModified = blobClient.getProperties().getLastModified();
                    System.out.println("Blob: " + blobItem.getName() + ", Last modified: " + lastModified);
                }
            System.out.println("No more blobs in the container");

        } catch (Exception e) {
            System.err.println("Azure storage error: " + e.getMessage());
        }
    }
}

Output log

2024-03-04 13:26:34.738 19528-19528 System.err              com...zureblobstoragepropertiestest  W  SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
2024-03-04 13:26:34.738 19528-19528 System.err              com...zureblobstoragepropertiestest  W  SLF4J: Defaulting to no-operation (NOP) logger implementation
2024-03-04 13:26:34.738 19528-19528 System.err              com...zureblobstoragepropertiestest  W  SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2024-03-04 13:26:34.752 19528-19528 epropertiestest         com...zureblobstoragepropertiestest  W  Accessing hidden method Ljava/lang/invoke/MethodHandles$Lookup;-><init>(Ljava/lang/Class;)V (max-target-o, reflection, denied)
2024-03-04 13:26:34.865 19528-19528 epropertiestest         com...zureblobstoragepropertiestest  W  Accessing hidden method Lsun/misc/VM;->maxDirectMemory()J (unsupported, reflection, allowed)
2024-03-04 13:26:34.867 19528-19528 PlatformDependent       com...zureblobstoragepropertiestest  I  Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system instability.
2024-03-04 13:26:34.968 19528-19528 epropertiestest         com...zureblobstoragepropertiestest  W  type=1400 audit(0.0:3344): avc: denied { read } for name="somaxconn" dev="proc" ino=195365 scontext=u:r:untrusted_app:s0:c194,c256,c512,c768 tcontext=u:object_r:proc_net:s0 tclass=file permissive=0 app=com.example.azureblobstoragepropertiestest
2024-03-04 13:26:34.989 19528-19528 epropertiestest         com...zureblobstoragepropertiestest  E  No implementation found for int io.netty.internal.tcnative.Library.aprMajorVersion() (tried Java_io_netty_internal_tcnative_Library_aprMajorVersion and Java_io_netty_internal_tcnative_Library_aprMajorVersion__)
2024-03-04 13:26:35.011 19528-19528 epropertiestest         com...zureblobstoragepropertiestest  E  No implementation found for int io.netty.channel.epoll.Native.offsetofEpollData() (tried Java_io_netty_channel_epoll_Native_offsetofEpollData and Java_io_netty_channel_epoll_Native_offsetofEpollData__)
2024-03-04 13:26:35.015 19528-19528 epropertiestest         com...zureblobstoragepropertiestest  E  No implementation found for int io.netty.channel.kqueue.Native.sizeofKEvent() (tried Java_io_netty_channel_kqueue_Native_sizeofKEvent and Java_io_netty_channel_kqueue_Native_sizeofKEvent__)
2024-03-04 13:26:35.022 19528-19528 epropertiestest         com...zureblobstoragepropertiestest  W  Accessing hidden field Lsun/nio/ch/SelectorImpl;->selectedKeys:Ljava/util/Set; (unsupported, reflection, allowed)
2024-03-04 13:26:35.022 19528-19528 epropertiestest         com...zureblobstoragepropertiestest  W  Accessing hidden field Lsun/nio/ch/SelectorImpl;->publicSelectedKeys:Ljava/util/Set; (unsupported, reflection, allowed)
2024-03-04 13:26:35.029 19528-19528 TrafficStats            com...zureblobstoragepropertiestest  D  tagSocket(130) with statsTag=0xffffffff, statsUid=-1
2024-03-04 13:26:35.031 19528-19528 Compatibil...geReporter com...zureblobstoragepropertiestest  D  Compat change id reported: 170188668; UID 10194; state: ENABLED
2024-03-04 13:26:35.033 19528-19528 MacAddressUtil          com...zureblobstoragepropertiestest  W  Failed to find a usable hardware address from the network interfaces; using random bytes: 6b:dd:5f:a8:87:5b:5e:0c
2024-03-04 13:26:35.346 19528-19528 System.out              com...zureblobstoragepropertiestest  I  Azure blob file downloaded successfully!
2024-03-04 13:26:35.352 19528-19528 System.out              com...zureblobstoragepropertiestest  I  File Content:
2024-03-04 13:26:35.352 19528-19528 System.out              com...zureblobstoragepropertiestest  I  This is a test blob uploaded to azure storage, to check if they can be downloaded.
2024-03-04 13:26:35.393 19528-19528 System.err              com...zureblobstoragepropertiestest  W  Get last modified of downloaded blob error: Wrong number of arguments; expected 1, got 0
2024-03-04 13:26:35.393 19528-19528 System.out              com...zureblobstoragepropertiestest  I  Blobs in the container:
2024-03-04 13:26:54.920 19528-19538 epropertiestest         com...zureblobstoragepropertiestest  I  Background concurrent copying GC freed 160645(16MB) AllocSpace objects, 16(336KB) LOS objects, 49% free, 9573KB/18MB, paused 197us,39us total 114.732ms
2024-03-04 13:26:54.923 19528-19540 System                  com...zureblobstoragepropertiestest  W  A resource failed to call close. 
2024-03-04 13:27:38.643 19528-19542 epropertiestest         com...zureblobstoragepropertiestest  I  Explicit concurrent copying GC freed 805(67KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 9574KB/18MB, paused 61us,40us total 70.543ms

here is a snippet from the azure portal, showing that the calls do go through. Azure activity.

from azure-sdk-for-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.