microsoftgraph / microsoftgraph/msgraph-sdk-java
Concurrent requests to send emails will generate duplicate emails, and the number does not match.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 444
- Forks
- 154
- Avg merge
- 18h 28m
- Merged PRs (30d)
- 4
Description
Hello!
I used Postman to iterate 160 times to send emails, and actually received 160+ emails. The number of emails received is random and does not match the number, which means duplicate emails are generated.
@PostMapping("/test") public void SysEmailController() { GraphEmailSender.testInfo(); }
`
import com.azure.identity.ClientSecretCredential;
import com.azure.identity.ClientSecretCredentialBuilder;
import com.microsoft.graph.models.EmailAddress;
import com.microsoft.graph.models.ItemBody;
import com.microsoft.graph.models.Message;
import com.microsoft.graph.models.Recipient;
import com.microsoft.graph.serviceclient.GraphServiceClient;
import com.microsoft.graph.users.item.sendmail.SendMailPostRequestBody;
import java.util.Collections;
import java.util.List;
public class GraphEmailSender {
// 配置参数
private static final String CLIENT_ID = "";
private static final String CLIENT_SECRET = "";
private static final String TENANT_ID = "";
private static final String SENDER_EMAIL = "";
private static final String[] SCOPES = new String[] { "https://graph.microsoft.com/.default" };
private static GraphServiceClient graphClient;
static {
try {
final ClientSecretCredential credential = new ClientSecretCredentialBuilder()
.clientId(CLIENT_ID)
.tenantId(TENANT_ID)
.clientSecret(CLIENT_SECRET)
.build();
if (null == credential) {
throw new Exception("Unexpected error");
}
graphClient = new GraphServiceClient(credential, SCOPES);
} catch (Exception e) {
System.err.println("init GraphServiceClient error: " + e.getMessage());
e.printStackTrace();
}
}
public static void testInfo() {
try {
Message message = new Message();
message.setSubject("test mail - Microsoft Graph API");
ItemBody body = new ItemBody();
body.setContent("Microsoft Graph API mail。");
message.setBody(body);
Recipient recipient = new Recipient();
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress("");
recipient.setEmailAddress(emailAddress);
List<Recipient> recipients = Collections.singletonList(recipient);
message.setToRecipients(recipients);
SendMailPostRequestBody sendMailPostRequestBody =
new SendMailPostRequestBody();
sendMailPostRequestBody.setMessage(message);
//
graphClient.users()
.byUserId(SENDER_EMAIL)
.sendMail()
.post(sendMailPostRequestBody);
System.out.println("send success!"+Thread.currentThread());
} catch (Exception e) {
System.err.println("error: " + e.getMessage());
e.printStackTrace();
}
}
}`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided @PostMapping("/test") entry point and GraphEmailSender.testInfo(), then reproduce the 160 concurrent sendMail requests using the shown Microsoft Graph client code. Compare request and delivery counts to determine whether the behavior is in the SDK or the calling application. Done means a reproducible SDK defect with a focused test or clear evidence that no SDK change is indicated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100