Ashinch / ReadYou

An Android RSS reader presented in Material You style.
GNU General Public License v3.0
4.34k stars 179 forks source link

NullPointerException occurred when adding a subscription in Google Reader #719

Closed Li-Jack closed 4 weeks ago

Li-Jack commented 4 weeks ago

1. Environment

2. Describe the bug

Version: 0.10.0 Device: HUAWEI ALN-AL80 System: Android 12 (API 31)

Stack trace:

java.lang.NullPointerException at me.ash.reader.domain.service.GoogleReaderRssService.subscribe(GoogleReaderRssService.kt:312) at me.ash.reader.domain.service.GoogleReaderRssService$subscribe$1.invokeSuspend(GoogleReaderRssService.kt:18) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:9) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:111) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:96) Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@352222f, Dispatchers.Default]

Ashinch commented 4 weeks ago

需要更详细的信息,比如前置的一些配置和操作过程

Li-Jack commented 4 weeks ago

使用Python 搭建一个简易 RSS 网站,用于浏览图片,RSS 地址:http://192.168.3.4:5001/rss.xml,下面为 app.py和 xml

project_root/
├── app.py
├── templates/
│   ├── index.html
│   ├── image.html
│   └── rss.xml
├── static/
│   └── images/
│       ├── image1.jpg
│       ├── image2.png
│       └── ...
└── ...
from flask import Flask, render_template, make_response
import os
from datetime import datetime

app = Flask(__name__)

@app.route('/')
def index():
    image_folder = os.path.join(app.static_folder, 'images')
    images = [f for f in os.listdir(image_folder) if os.path.isfile(os.path.join(image_folder, f))]
    return render_template('index.html', images=images)

@app.route('/images/<filename>')
def image_page(filename):
    return render_template('image.html', filename=filename)

@app.route('/rss.xml')
def rss_feed():
    image_folder = os.path.join(app.static_folder, 'images')
    images = [f for f in os.listdir(image_folder) if os.path.isfile(os.path.join(image_folder, f))]

    rss_items = []
    for image in images:
        image_url = f"http://192.168.3.4:5001/static/images/{image}"
        description = f"<img src='{image_url}' referrerpolicy='no-referrer'>"

        rss_item = {
            'title': 'New Image',  # 更普适的标题
            'link': f"http://192.168.3.4:5001/images/{image}",
            'description': description,
            'pubDate': datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S +0000')
        }
        rss_items.append(rss_item)

    rss = render_template('rss.xml', items=rss_items, datetime=datetime)
    response = make_response(rss)
    response.headers['Content-Type'] = 'application/rss+xml'
    return response

if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0', port=5001)
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
    <channel>
        <title>My Image RSS Feed</title>
        <link>http://192.168.3.4:5001/</link>
        <description>A simple RSS feed of images</description>
        <lastBuildDate>{{ datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S +0000') }}</lastBuildDate>
        <pubDate>{{ datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S +0000') }}</pubDate>
        <ttl>1800</ttl>

        {% for item in items %}
        <item>
            <title>{{ item.title }}</title>
            <link>{{ item.link }}</link>
            <description>{{ item.description }}</description>
            <pubDate>{{ item.pubDate }}</pubDate>
        </item>
        {% endfor %}
    </channel>
</rss>
Li-Jack commented 4 weeks ago

@Ashinch

Li-Jack commented 4 weeks ago

使用 reeder 5 以及NetNewsWire,RSS 可以正常解析

Ashinch commented 4 weeks ago

是在 Google Reader 类型的账户里添加的订阅吗?

Li-Jack commented 4 weeks ago

本地添加

Ashinch commented 4 weeks ago

本地添加

这个错误是发生在 Google Reader 类型的账户在添加订阅时,此时会将 rss 链接交给 Google Reader 服务去订阅,然后再从 Google Reader 服务中拿数据。问题就发生在 Google Reader 服务无法访问到这个 rss 链接,然后 app 没有做空处理就报错了。

如果你要本地添加的话,要先点击账户名去切换到本地账户,再添加订阅。


This error occurs with accounts of type “Google Reader” when adding a subscription. The app sends the RSS link to the Google Reader service for subscription and retrieves data from the service. The issue arises when the Google Reader service cannot access the RSS link, causing an error due to lack of null handling.

For local additions, you need to first click on the account name to switch to the local account before adding a subscription.

Li-Jack commented 4 weeks ago

切换到本地订阅,问题解决了,Thanks♪(・ω・)ノ