anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: thundernest/k-9
Issue: Import functionality is almost broken

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
### 1
1. Export k9s_settings on older App version.
2. Remove older App version.
3. Install build v5.727.
4. Have firewall block App from internet.
5. Import all previously exported settings.
6. (Optional) Enable Internet access for App.
7. All Mail accounts have only an empty "Outbox" folder.

### 2
1. Export k9s_settings on older App version.
2. Remove older App version.
3. Install build v5.727.
4. Let App have internet access.
5. Import all previously exported settings.
6. Provide wrong password for any amount of mail accounts.
7. All Mail accounts, that were provided with a wrong password, have only an empty "Outbox" folder.
8. Remove faulty Mail account.
9. Re-import this faulty mail account, only.
10. The empty "Outbox" folder is now the default folder on top of all folders.
11. Every time you change to this mail account, the "Outbox" folder will _always_ be the first one opened on top.
12. There is no way to set the "Inbox" folder back to top.

This is only a summary of all the issues. There are more very similar issues, that I do not want to repeat here.
In short, the Import functionality is almost broken; if you just make 1 mistake, you have to uninstall and re-install the whole application. This is no way to treat imports.

**Expected behavior**
Importing works smoothly.

**Environment (please complete the following information):**
 - K-9 Mail version: v5.727
 - Android version: 11
 - Device: POCO X3
 - Account type: Generic IMAP

**Additional context**
The "stable" version always crashes, when I try to import settings. That's why I am using the newest "Pre-Release" version.

**Logs**
Please take some time to [retrieve logs](https://github.com/k9mail/k-9/wiki/LoggingErrors) and attach them here:
No, I will not uninstall and re-install the App for the 7th time.



Changed files:
app/core/src/main/java/com/fsck/k9/controller/MessagingController.java

diff --git a/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java b/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java
index 67c365a44..38fb82ca2 100644
--- a/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java
+++ b/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java
@@ -2356,6 +2356,8 @@ public class MessagingController {
 
         sendPendingMessages(account, listener);
 
+        refreshFolderListIfStale(account);
+
         try {
             Account.FolderMode aDisplayMode = account.getFolderDisplayMode();
             Account.FolderMode aSyncMode = account.getFolderSyncMode();
Repository: thundernest/k-9
Issue: Email address too long for line

**Describe the bug**
A mail address that is too long to fit on the display won't be accepted as one address but two (or more) addresses.

**To Reproduce**
Try to send an email to an address that is too long for your display width, for example `abcdefghijklmnopqrstuvwxyz@outlook.com`. The app will now display the address in two lines, in my case like this:
`abcdefghijklmnopqrstuvwxyz@outlook.
com`
The app will now see every line as single address and think you want to send mails to `abcdefghijklmnopqrstuvwxyz@outlook.` and `com`.

**Expected behavior**
The app should see the address as a single one, even after a new line.

**Environment**
 - K-9 Mail version: 5.721
 - Android version: 10
 - Device: Samsung Galaxy A9

Changed files:
app/ui/legacy/src/main/java/com/fsck/k9/view/RecipientSelectView.java

diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/view/RecipientSelectView.java b/app/ui/legacy/src/main/java/com/fsck/k9/view/RecipientSelectView.java
index 8e5452e08..72e46e091 100644
--- a/app/ui/legacy/src/main/java/com/fsck/k9/view/RecipientSelectView.java
+++ b/app/ui/legacy/src/main/java/com/fsck/k9/view/RecipientSelectView.java
@@ -204,6 +204,10 @@ public class RecipientSelectView extends TokenCompleteTextView<Recipient> implem
 
     @Override
     public void onFocusChanged(boolean hasFocus, int direction, Rect previous) {
+        if (!hasFocus) {
+            performCompletion();
+        }
+
         super.onFocusChanged(hasFocus, direction, previous);
         if (hasFocus) {
             displayKeyboard();
Repository: thundernest/k-9
Issue: CC/BCC Disappear if you tap subject first

### Expected behavior
While composing a new email, if I type the subject first, and compose the email, THEN go back and fill out the addresses of BCC and CC.

### Actual behavior
While composing a new email, if I type the subject first,  the BCC and CC address fields disappear (have them configured to show by default).   No way to get them back because the BCC/CC icon is missing (see previous issue)

### Steps to reproduce
1.  Tap to compose a new email
2.   Tap and type a subject
3.    BCC/CC address fields disappear

### Environment
K-9 Mail version:   5.201

Android version: 6.0

Account type (IMAP, POP3, WebDAV/Exchange):IMAP


Changed files:
k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java

diff --git a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java
index cf805041d..be62c922a 100644
--- a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java
+++ b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java
@@ -541,7 +541,9 @@ public class RecipientPresenter implements PermissionPingCallback {
     }
 
     public void onNonRecipientFieldFocused() {
-        hideEmptyExtendedRecipientFields();
+        if (!account.isAlwaysShowCcBcc()) {
+            hideEmptyExtendedRecipientFields();
+        }
     }
 
     public void onClickCryptoStatus() {
Repository: thundernest/k-9
Issue: Crash when clicking compose button in message list widget

**Describe the bug**
Clicking the envelope icon in the message list widget crashes the app.

**To Reproduce**
Steps to reproduce the behavior:
1. Set up an account
2. Drag the message list widget to a home screen
3. Click the envelope icon (compose message) in the upper right of the home screen widget
4. Observe app crash

**Environment (please complete the following information):**
 - K-9 Mail version: 5.734-SNAPSHOT

**Logs**
```
Caused by: java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter accountUuid
   at com.fsck.k9.Preferences.getAccount(Unknown Source:2)
   at com.fsck.k9.activity.MessageCompose.onCreate(MessageCompose.java:284)
```

Changed files:
app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageCompose.java

diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageCompose.java b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageCompose.java
index 0601958fd..c2cb3fd28 100644
--- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageCompose.java
+++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageCompose.java
@@ -281,7 +281,9 @@ public class MessageCompose extends K9Activity implements OnClickListener,
                 relatedMessageReference.getAccountUuid() :
                 intent.getStringExtra(EXTRA_ACCOUNT);
 
-        account = preferences.getAccount(accountUuid);
+        if (accountUuid != null) {
+            account = preferences.getAccount(accountUuid);
+        }
 
         if (account == null) {
             account = preferences.getDefaultAccount();
Repository: thundernest/k-9
Issue: twitter background image - td element

the background images (for previewing videos in the twitter e-mails) aren't displayed for some reason.

[twitter.zip](https://github.com/k9mail/k-9/files/1667936/twitter.zip)

Could you pls take a look? :)

Regards,
Djfe


Changed files:
k9mail/src/main/java/com/fsck/k9/message/html/HtmlSanitizer.java

diff --git a/k9mail/src/main/java/com/fsck/k9/message/html/HtmlSanitizer.java b/k9mail/src/main/java/com/fsck/k9/message/html/HtmlSanitizer.java
index 1707f7c9e..ad11115fc 100644
--- a/k9mail/src/main/java/com/fsck/k9/message/html/HtmlSanitizer.java
+++ b/k9mail/src/main/java/com/fsck/k9/message/html/HtmlSanitizer.java
@@ -17,13 +17,13 @@ public class HtmlSanitizer {
                 .addAttributes("font", "color", "face", "size")
                 .addAttributes("table", "align", "background", "bgcolor", "border", "cellpadding", "cellspacing",
                         "width")
-                .addAttributes("tr", "align", "bgcolor", "valign")
+                .addAttributes("tr", "align", "background", "bgcolor", "valign")
                 .addAttributes("th",
-                        "align", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "sorted",
-                        "valign", "width")
+                        "align", "background", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope",
+                        "sorted", "valign", "width")
                 .addAttributes("td",
-                        "align", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign",
-                        "width")
+                        "align", "background", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope",
+                        "valign", "width")
                 .addAttributes("map", "name")
                 .addAttributes("area", "shape", "coords", "href", "alt")
                 .addProtocols("area", "href", "http", "https")
Repository: thundernest/k-9
Issue: Contact auto selecting first item

If there are "FirstUser@example.com" and "SecondUser@example.com" in my Contacts and i type "User@example.com" then app selects first entry from contacts and i cannot send email to "User@example.com". Previous versions allowed me type address and select one from suggestions if i want. Work around is to end the address with a comma & a space so new address object is created. 

K-9 Mail version:
5.201



Changed files:
k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java

diff --git a/k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java b/k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java
index 28ca83b25..bae224116 100644
--- a/k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java
+++ b/k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java
@@ -229,14 +229,9 @@ public class RecipientSelectView extends TokenCompleteTextView<Recipient> implem
     @Override
     public void performCompletion() {
         if (getListSelection() == ListView.INVALID_POSITION && enoughToFilter()) {
-            Object bestGuess;
-            if (getAdapter().getCount() > 0) {
-                bestGuess = getAdapter().getItem(0);
-            } else {
-                bestGuess = defaultObject(currentCompletionText());
-            }
-            if (bestGuess != null) {
-                replaceText(convertSelectionToString(bestGuess));
+            Object recipientText = defaultObject(currentCompletionText());
+            if (recipientText != null) {
+                replaceText(convertSelectionToString(recipientText));
             }
         } else {
             super.performCompletion();
Repository: thundernest/k-9
Issue: Wrong OpenPGP key used when sending signed-only email

I have recently noticed that if I set the sending of an email with the openpgp signature only option, I don't have the possibility to choose which identity to use.  k9 v5.718 uses the first signature key available in openkeychain although it is not even that of the email from which I send.  then an email is sent with the address xxx @ xxx signed by a yyyu @ yyy identity how to choose which signature key to use?  I have no choices

Changed files:
app/ui/legacy/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java

diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java b/app/ui/legacy/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java
index a9e1ace70..66b261bed 100644
--- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java
+++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java
@@ -364,6 +364,7 @@ public class RecipientPresenter {
     public void onSwitchIdentity(Identity identity) {
 
         // TODO decide what actually to do on identity switch?
+        asyncUpdateCryptoStatus();
         /*
         if (mIdentityChanged) {
             mBccWrapper.setVisibility(View.VISIBLE);
Repository: thundernest/k-9
Issue: Umlauts in encrypted headings 

When I sent a mail with the heading "Test verschlüsselt", it after receiving it read "?ISO-8859-1?Q?Test_verschl=FCsselt_?=". 

Changed files:
app/core/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractor.java

diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractor.java b/app/core/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractor.java
index 3d902654e..4499e955b 100644
--- a/app/core/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractor.java
+++ b/app/core/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractor.java
@@ -107,7 +107,7 @@ public class MessageViewInfoExtractor {
 
         boolean hasProtectedSubject = "v1".equalsIgnoreCase(protectedHeadersParam) && protectedSubjectHeader.length > 0;
         if (hasProtectedSubject) {
-            return protectedSubjectHeader[0];
+            return MimeUtility.unfoldAndDecode(protectedSubjectHeader[0]);
         }
 
         return null;
Repository: thundernest/k-9
Issue: Crash when attachment file is changed while TC document picker dialog is open

### Expected behavior
error message "File not found"
or
Folder rescan when switching back to file picker (TC issue)

### Actual behavior
short glimpse of mail editor with attached file, then app crash

### Steps to reproduce
1. Compose mail
2. open file attachment dialog
3. select "Total Commander"
5. navigate to folder X
6. Switch to some file browser and rename file Y in folder X
7. Switch back to K-9, select file Y (under old filename), attach

- with "TotalCmd (file://url)" - nothing is attached
- same with Picasa 
- stock album or "Simple Gallery" manage to attach the image anyway, but under a generic number

### Environment
K-9 Mail version:
5.6
Android version:
7.1.1

Account type (IMAP, POP3, WebDAV/Exchange):
IMAP

Please take some time to [retrieve logs](https://github.com/k9mail/k-9/wiki/LoggingErrors) and attach them here:
[k9-log.txt](https://github.com/k9mail/k-9/files/4688569/k9-log.txt)


Changed files:
app/ui/legacy/src/main/java/com/fsck/k9/activity/loader/AttachmentContentLoader.java

diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/loader/AttachmentContentLoader.java b/app/ui/legacy/src/main/java/com/fsck/k9/activity/loader/AttachmentContentLoader.java
index 1da4ce6e5..5c699dcf8 100644
--- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/loader/AttachmentContentLoader.java
+++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/loader/AttachmentContentLoader.java
@@ -60,6 +60,13 @@ public class AttachmentContentLoader extends AsyncTaskLoader<Attachment> {
 
             SafeContentResolver safeContentResolver = SafeContentResolver.newInstance(context);
             InputStream in = safeContentResolver.openInputStream(sourceAttachment.uri);
+            if (in == null) {
+                Timber.w("Error opening attachment for reading: %s", sourceAttachment.uri);
+
+                cachedResultAttachment = sourceAttachment.deriveWithLoadCancelled();
+                return cachedResultAttachment;
+            }
+
             try {
                 FileOutputStream out = new FileOutputStream(file);
                 try {
Repository: thundernest/k-9
Issue: POP3: trash folder remains empty

Hi,
When i delete a mail, the trash folder remains empty
[log.txt](https://github.com/k9mail/k-9/files/4505545/log.txt)


### Expected behavior
Deleted mail should be found in the trash folder

### Actual behavior
No mail is found in the trash folder

### Steps to reproduce
1. delete a mail
2. go to the trash folder
3. see if the deleted mail is in the folder

### Environment
K-9 Mail version: 5.708

Android version: 10

Account type (IMAP, POP3, WebDAV/Exchange): pop3


Changed files:
app/core/src/main/java/com/fsck/k9/controller/MessagingController.java

diff --git a/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java b/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java
index 337b8c54a..785bd60e5 100644
--- a/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java
+++ b/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java
@@ -2034,7 +2034,7 @@ public class MessagingController {
             localFolder = localStore.getFolder(folder);
             Map<String, String> uidMap = null;
             if (folder.equals(account.getTrashFolder()) || !account.hasTrashFolder() ||
-                    !backend.isDeleteMoveToTrash()) {
+                    (backend.getSupportsTrashFolder() && !backend.isDeleteMoveToTrash())) {
                 Timber.d("Not moving deleted messages to local Trash folder. Removing local copies.");
 
                 if (!localOnlyMessages.isEmpty()) {
Repository: thundernest/k-9
Issue: URL at the beginning of a line in plain text body isn't linkified

This happens because we first convert the plain text to HTML and end up with something like:

```html
<br>http://uri.example.org<br>
```

But right now only supported schemes preceded by a space, a newline, or an opening parenthesis are candidates for linkifying.

https://github.com/k9mail/k-9/blob/27bc562ebe37bc139b84c13142681dbfe5640688/k9mail/src/main/java/com/fsck/k9/message/html/UriLinkifier.java#L16

Changed files:
k9mail/src/test/java/com/fsck/k9/message/html/UriLinkifierTest.java, k9mail/src/main/java/com/fsck/k9/message/html/UriLinkifier.java

diff --git a/k9mail/src/main/java/com/fsck/k9/message/html/UriLinkifier.java b/k9mail/src/main/java/com/fsck/k9/message/html/UriLinkifier.java
index 815acc5ce..3d2565f27 100644
--- a/k9mail/src/main/java/com/fsck/k9/message/html/UriLinkifier.java
+++ b/k9mail/src/main/java/com/fsck/k9/message/html/UriLinkifier.java
@@ -13,7 +13,7 @@ import android.text.TextUtils;
 public class UriLinkifier {
     private static final Pattern URI_SCHEME;
     private static final Map<String, UriParser> SUPPORTED_URIS;
-    private static final String SCHEME_SEPARATORS = " (\\\\n";
+    private static final String SCHEME_SEPARATORS = " (\\\\n>";
     private static final String ALLOWED_SEPARATORS_PATTERN = "(?:^|[" + SCHEME_SEPARATORS + "])";
 
     static {
diff --git a/k9mail/src/test/java/com/fsck/k9/message/html/UriLinkifierTest.java b/k9mail/src/test/java/com/fsck/k9/message/html/UriLinkifierTest.java
index 3b02dc035..81abbbb34 100644
--- a/k9mail/src/test/java/com/fsck/k9/message/html/UriLinkifierTest.java
+++ b/k9mail/src/test/java/com/fsck/k9/message/html/UriLinkifierTest.java
@@ -136,4 +136,13 @@ public class UriLinkifierTest {
                         "<a href=\\"http://uri2.example.org/path\\">http://uri2.example.org/path</a> postfix",
                 outputBuffer.toString());
     }
+
+    @Test
+    public void uriSurroundedByHtmlTags() {
+        String text = "<br>http://uri.example.org<hr>";
+
+        UriLinkifier.linkifyText(text, outputBuffer);
+
+        assertEquals("<br><a href=\\"http://uri.example.org\\">http://uri.example.org</a><hr>", outputBuffer.toString());
+    }
 }
Repository: thundernest/k-9
Issue: App crashes when I click on contact logo

Hi,
I've not found a recent issue related to my issue.

Thanks for your answer

### Expected behavior
It should be create a new message with the clicked contact, as recipient.

### Actual behavior
Since the update, the app crashes when I click on contact logo square.

### Steps to reproduce
1. Open the app
2. Click on the logo square of any email
3. The app will crash

### Environment
K-9 Mail version: 5.403

Android version: 5.1 with Flyme 6.2.0.0A

Account type (IMAP, POP3, WebDAV/Exchange): IMAP with Gmail


Changed files:
k9mail/src/main/java/com/fsck/k9/ui/ContactBadge.java

diff --git a/k9mail/src/main/java/com/fsck/k9/ui/ContactBadge.java b/k9mail/src/main/java/com/fsck/k9/ui/ContactBadge.java
index fbea32426..6a09fedca 100644
--- a/k9mail/src/main/java/com/fsck/k9/ui/ContactBadge.java
+++ b/k9mail/src/main/java/com/fsck/k9/ui/ContactBadge.java
@@ -1,6 +1,7 @@
 package com.fsck.k9.ui;
 
 
+import android.content.ActivityNotFoundException;
 import android.content.AsyncQueryHandler;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -20,6 +21,9 @@ import android.view.View.OnClickListener;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityNodeInfo;
 import android.widget.ImageView;
+import android.widget.Toast;
+
+import com.fsck.k9.R;
 
 
 /**
@@ -207,10 +211,14 @@ public class ContactBadge extends ImageView implements OnClickListener {
                         getContext(), ContactBadge.this, lookupUri, QuickContact.MODE_LARGE, null);
             } else if (createUri != null) {
                 // Prompt user to add this person to contacts
-                final Intent intent = new Intent(Intents.SHOW_OR_CREATE_CONTACT, createUri);
-                extras.remove(EXTRA_URI_CONTENT);
-                intent.putExtras(extras);
-                getContext().startActivity(intent);
+                try {
+                    final Intent intent = new Intent(Intents.SHOW_OR_CREATE_CONTACT, createUri);
+                    extras.remove(EXTRA_URI_CONTENT);
+                    intent.putExtras(extras);
+                    getContext().startActivity(intent);
+                } catch (ActivityNotFoundException e) {
+                    Toast.makeText(getContext(), R.string.error_activity_not_found, Toast.LENGTH_LONG).show();
+                }
             }
         }
     }
Repository: thundernest/k-9
Issue: Export settings  does not export 'Support signing of unecrypted mail' setting

If I set 'Support signing of unecrypted mail' option, then export the settings, then clear K9 mail app. data, then import the settings, the 'Support signing of unecrypted mail' option does not get set.

Changed files:
k9mail/src/main/java/com/fsck/k9/preferences/GlobalSettings.java

diff --git a/k9mail/src/main/java/com/fsck/k9/preferences/GlobalSettings.java b/k9mail/src/main/java/com/fsck/k9/preferences/GlobalSettings.java
index 14c77e63e..f1a799ed9 100644
--- a/k9mail/src/main/java/com/fsck/k9/preferences/GlobalSettings.java
+++ b/k9mail/src/main/java/com/fsck/k9/preferences/GlobalSettings.java
@@ -285,10 +285,10 @@ public class GlobalSettings {
         s.put("pgpSignOnlyDialogCounter", Settings.versions(
                 new V(45, new IntegerRangeSetting(0, Integer.MAX_VALUE, 0))
         ));
-        s.put("openpgpProvider", Settings.versions(
+        s.put("openPgpProvider", Settings.versions(
                 new V(46, new StringSetting(K9.NO_OPENPGP_PROVIDER))
         ));
-        s.put("openpgpSupportSignOnly", Settings.versions(
+        s.put("openPgpSupportSignOnly", Settings.versions(
                 new V(47, new BooleanSetting(false))
         ));
Repository: spring-projects/spring-security
Issue: CasAuthenticationFilter.successfulAuthentication missing call to securityContextRepository.saveContext

**Describe the bug**
`org.springframework.security.cas.web.CasAuthenticationFilter.successfulAuthentication` seems to be missing a call to `securityContextRepository.saveContext` as per [the Spring 6 migration document](https://docs.spring.io/spring-security/reference/migration/servlet/session-management.html). I think this makes the filter completely unusable on Spring6/Boot3 and begs to question if the `CasAuthenticationFilter` code is production ready for Spring 6 otherwise.

**To Reproduce**
Use the filter

**Expected behavior**
SecurityContext is saved between requests :)


Changed files:
cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationFilter.java

diff --git a/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationFilter.java b/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationFilter.java
index a951168f66..6f2920b3d0 100644
--- a/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationFilter.java
+++ b/cas/src/main/java/org/springframework/security/cas/web/CasAuthenticationFilter.java
@@ -42,6 +42,7 @@ import org.springframework.security.web.authentication.AbstractAuthenticationPro
 import org.springframework.security.web.authentication.AuthenticationFailureHandler;
 import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
 import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
+import org.springframework.security.web.context.SecurityContextRepository;
 import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
 import org.springframework.security.web.util.matcher.RequestMatcher;
 import org.springframework.util.Assert;
@@ -192,10 +193,12 @@ public class CasAuthenticationFilter extends AbstractAuthenticationProcessingFil
 
 	private AuthenticationFailureHandler proxyFailureHandler = new SimpleUrlAuthenticationFailureHandler();
 
+	private SecurityContextRepository securityContextRepository= new HttpSessionSecurityContextRepository();
+
 	public CasAuthenticationFilter() {
 		super("/login/cas");
 		setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler());
-		setSecurityContextRepository(new HttpSessionSecurityContextRepository());
+		setSecurityContextRepository(this.securityContextRepository);
 	}
 
 	@Override
@@ -211,6 +214,7 @@ public class CasAuthenticationFilter extends AbstractAuthenticationProcessingFil
 		SecurityContext context = SecurityContextHolder.createEmptyContext();
 		context.setAuthentication(authResult);
 		SecurityContextHolder.setContext(context);
+		this.securityContextRepository.saveContext(context,request,response);
 		if (this.eventPublisher != null) {
 			this.eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent(authResult, this.getClass()));
 		}
Repository: swagger-api/swagger-core
Issue: Example Value overwrites Parameter's DataType

Hi,

I encountered the following unexpected behavior. When specifying an example value in a `@ApiImplicitParam` annotation the parameter's dataType will be set to the example value.

For instance annotation

``` java
@ApiImplicitParam(name="id", paramType="path", dataType="string", example="123456")
```

will lead to JSON

``` json
"parameters":
[{"name":"id",
  "in":"path",
  "type":"123456",
  "x-example":"123456"}]
```

This behavior was observed on swagger 1.5.4.

Cause is the `ParameterProcessor.applyAnnotations()` method. The following code found in the method overwrites the parameter's dataType:

``` java
  if (StringUtils.isNotEmpty(param.getExample())) {
        p.setType(param.getExample());
  }
```

I am not really sure about the original intention of the code but it does not look right to me. The code was introduced by commit 62c100f33a54d7688e859cd011abb89a907e02ef "added example support for non-body params, implicits".

Best regards,

phosn


Changed files:
modules/swagger-core/src/main/java/io/swagger/util/ParameterProcessor.java
modules/swagger-jaxrs/src/test/java/io/swagger/resources/ResourceWithImplicitFileParam.java

diff --git a/modules/swagger-core/src/main/java/io/swagger/util/ParameterProcessor.java b/modules/swagger-core/src/main/java/io/swagger/util/ParameterProcessor.java
index b75656013..adb4106f0 100644
--- a/modules/swagger-core/src/main/java/io/swagger/util/ParameterProcessor.java
+++ b/modules/swagger-core/src/main/java/io/swagger/util/ParameterProcessor.java
@@ -67,9 +67,6 @@ public class ParameterProcessor {
                     p.setType(param.getDataType());
                 }
             }
-            if (StringUtils.isNotEmpty(param.getExample())) {
-                p.setType(param.getExample());
-            }
             if (helper.getMinItems() != null) {
                 p.setMinItems(helper.getMinItems());
             }
diff --git a/modules/swagger-jaxrs/src/test/java/io/swagger/resources/ResourceWithImplicitFileParam.java b/modules/swagger-jaxrs/src/test/java/io/swagger/resources/ResourceWithImplicitFileParam.java
index 63f6d5da6..fbf438d74 100644
--- a/modules/swagger-jaxrs/src/test/java/io/swagger/resources/ResourceWithImplicitFileParam.java
+++ b/modules/swagger-jaxrs/src/test/java/io/swagger/resources/ResourceWithImplicitFileParam.java
@@ -13,7 +13,7 @@ public class ResourceWithImplicitFileParam {
     @POST
     @Path("/testString")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "sort", paramType = "form", dataType = "java.io.File", required = false, value = "file to upload")
+      @ApiImplicitParam(name = "sort", paramType = "form", dataType = "java.io.File", required = false, value = "file to upload")
     })
     @ApiOperation("Test operation with implicit parameters")
     public void testImplicitFileParam() {
Repository: swagger-api/swagger-core
Issue: The ApiOperation.nickname property does not work

The reason: please check this class:  io.swagger.jaxrs.Reader, line 711
I think there should be: operationId = apiOperation.nickname();
instead of: operationId = method.getName();

Sincerely yours
Nazar


Changed files:
modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/Reader.java

diff --git a/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/Reader.java b/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/Reader.java
index 937ec0a52..464d77c2a 100644
--- a/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/Reader.java
+++ b/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/Reader.java
@@ -714,7 +714,7 @@ public class Reader {
                 return null;
             }
             if (!"".equals(apiOperation.nickname())) {
-                operationId = method.getName();
+                operationId = apiOperation.nickname();
             }
 
             defaultResponseHeaders = parseResponseHeaders(apiOperation.responseHeaders());
Repository: swagger-api/swagger-core
Issue: Change logging level to DEBUG for some messages in PropertyBuilder

Change logging level for [this](https://github.com/swagger-api/swagger-core/blob/400662d7253c0c2efb14316f8948ddc61a60069e/modules/swagger-models/src/main/java/io/swagger/models/properties/PropertyBuilder.java#L569) message to DEBUG as these messages look confusing for [codegen](https://github.com/swagger-api/swagger-codegen) users (https://github.com/swagger-api/swagger-parser/issues/60).


Changed files:
modules/swagger-models/src/main/java/io/swagger/models/properties/PropertyBuilder.java

diff --git a/modules/swagger-models/src/main/java/io/swagger/models/properties/PropertyBuilder.java b/modules/swagger-models/src/main/java/io/swagger/models/properties/PropertyBuilder.java
index 41fbdf96a..660d11c86 100644
--- a/modules/swagger-models/src/main/java/io/swagger/models/properties/PropertyBuilder.java
+++ b/modules/swagger-models/src/main/java/io/swagger/models/properties/PropertyBuilder.java
@@ -566,7 +566,7 @@ public class PropertyBuilder {
                     return item;
                 }
             }
-            LOGGER.error("no property for " + type + ", " + format);
+            LOGGER.debug("no property for " + type + ", " + format);
             return null;
         }
Repository: swagger-api/swagger-core
Issue: 'hidden' variable is not used

'hidden' variable is declared, but isn't used https://github.com/swagger-api/swagger-core/blob/9c67549cc4e30db916dac0165f0549485a6eb4c7/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/Reader.java#L834-L837


Changed files:
modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/Reader.java

diff --git a/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/Reader.java b/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/Reader.java
index 1657326ca..145416564 100644
--- a/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/Reader.java
+++ b/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/Reader.java
@@ -829,11 +829,6 @@ public class Reader {
             operation.setDeprecated(true);
         }
 
-        boolean hidden = false;
-        if (apiOperation != null) {
-            hidden = apiOperation.hidden();
-        }
-
         // process parameters
         for (Parameter globalParameter : globalParameters) {
             operation.parameter(globalParameter);
Repository: swagger-api/swagger-core
Issue: NPE without any class with @Api annotation

If there is no class with `@Api` annotation trying to get `swagger.json` causes NPE. This may be very confusing at the beginning, when we are implementing Swagger step-by-step and get exception.

Stack:

```
java.lang.NullPointerException
    at com.wordnik.swagger.jaxrs.config.BeanConfig.configure(BeanConfig.java:196)
    at com.wordnik.swagger.jaxrs.listing.ApiListingResource.scan(ApiListingResource.java:52)
    at com.wordnik.swagger.jaxrs.listing.ApiListingResource.getListingJson(ApiListingResource.java:79)
    ...
```

So we have to check for nulls somewhere in this area: https://github.com/swagger-api/swagger-core/blob/c4260bea041027f9887c67d5d6c6eb408c238969/modules/swagger-jaxrs/src/main/java/com/wordnik/swagger/jaxrs/config/BeanConfig.java#L197


Changed files:
modules/swagger-jaxrs/src/main/java/com/wordnik/swagger/jaxrs/Reader.java

diff --git a/modules/swagger-jaxrs/src/main/java/com/wordnik/swagger/jaxrs/Reader.java b/modules/swagger-jaxrs/src/main/java/com/wordnik/swagger/jaxrs/Reader.java
index 0574c9891..23aea9a17 100644
--- a/modules/swagger-jaxrs/src/main/java/com/wordnik/swagger/jaxrs/Reader.java
+++ b/modules/swagger-jaxrs/src/main/java/com/wordnik/swagger/jaxrs/Reader.java
@@ -58,7 +58,7 @@ public class Reader {
   static ObjectMapper m = Json.mapper();
 
   public Reader(Swagger swagger) {
-    this.swagger = swagger;
+    this.swagger = swagger == null ? new Swagger() : swagger;
   }
 
   public Swagger read(Set<Class<?>> classes) {
@@ -76,8 +76,6 @@ public class Reader {
   }
 
   protected Swagger read(Class<?> cls, String parentPath, String parentMethod, boolean readHidden, String[] parentConsumes, String[] parentProduces, Map<String, Tag> parentTags, List<Parameter> parentParameters) {
-    if(swagger == null)
-      swagger = new Swagger();
     Api api = (Api) cls.getAnnotation(Api.class);
     Map<String, SecurityScope> globalScopes = new HashMap<String, SecurityScope>();
Repository: swagger-api/swagger-core
Issue: jersey2 listing resource broken

1.5.8 seems to have broken the listing resource for jersey2.  Now this class:

``` java
package io.swagger.jersey.listing;

/* */
@Path("/")
public class ApiListingResourceJSON
        extends ApiListingResource {
}
```

causes the swagger definition to appear only on `"/"` instead of `"/swagger.{type:json|yaml}"` as defined in the `io.swagger.jaxrs.listing.ApiListingResource` class

The solution is to use `io.swagger.jaxrs.listing.ApiListingResource`, but for previous uses (like swagger-generator), the 1.5.8 changes break the resource.

We should either fix the ApiListingResourceJSON, remove it, or make it clear how to update when going to 1.5.8.


Changed files:
modules/swagger-jersey2-jaxrs/src/main/java/io/swagger/jersey/listing/ApiListingResourceJSON.java

diff --git a/modules/swagger-jersey2-jaxrs/src/main/java/io/swagger/jersey/listing/ApiListingResourceJSON.java b/modules/swagger-jersey2-jaxrs/src/main/java/io/swagger/jersey/listing/ApiListingResourceJSON.java
index 05a54d0cf..dbe40f642 100644
--- a/modules/swagger-jersey2-jaxrs/src/main/java/io/swagger/jersey/listing/ApiListingResourceJSON.java
+++ b/modules/swagger-jersey2-jaxrs/src/main/java/io/swagger/jersey/listing/ApiListingResourceJSON.java
@@ -2,9 +2,7 @@ package io.swagger.jersey.listing;
 
 import io.swagger.jaxrs.listing.ApiListingResource;
 
-import javax.ws.rs.Path;
-
-@Path("/")
+@Deprecated
 public class ApiListingResourceJSON
         extends ApiListingResource {
 }
\\ No newline at end of file